public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] enr: Fetch module items during early name resolution
@ 2023-03-14 11:44 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-14 11:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:362c6d7f14bfc84a670bd84a4ea11ae3da916fa9

commit 362c6d7f14bfc84a670bd84a4ea11ae3da916fa9
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Thu Mar 2 16:56:33 2023 +0100

    enr: Fetch module items during early name resolution
    
    This is important as public macros can be present in other modules,
    which would otherwise not be loaded until the expansion phase
    happening right after the early name resolution.
    
    gcc/rust/ChangeLog:
    
            * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Move
            unloaded module item loading to...
            * expand/rust-attribute-visitor.cc (AttrVisitor::visit): ...here.

Diff:
---
 gcc/rust/expand/rust-attribute-visitor.cc    | 9 ---------
 gcc/rust/resolve/rust-early-name-resolver.cc | 6 ++++++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gcc/rust/expand/rust-attribute-visitor.cc b/gcc/rust/expand/rust-attribute-visitor.cc
index d416505eeaf..13ae28c0b5e 100644
--- a/gcc/rust/expand/rust-attribute-visitor.cc
+++ b/gcc/rust/expand/rust-attribute-visitor.cc
@@ -2148,15 +2148,6 @@ AttrVisitor::visit (AST::Module &module)
 	}
     }
 
-  // Parse the module's items if they haven't been expanded and the file
-  // should be parsed (i.e isn't hidden behind an untrue or impossible cfg
-  // directive)
-  if (!module.is_marked_for_strip ()
-      && module.get_kind () == AST::Module::ModuleKind::UNLOADED)
-    {
-      module.load_items ();
-    }
-
   // strip items if required
   expand_pointer_allow_strip (module.get_items ());
 }
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index 69852280630..b3fb5a8df96 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -581,6 +581,12 @@ EarlyNameResolver::visit (AST::Method &method)
 void
 EarlyNameResolver::visit (AST::Module &module)
 {
+  // Parse the module's items if they haven't been expanded and the file
+  // should be parsed (i.e isn't hidden behind an untrue or impossible cfg
+  // directive)
+  if (module.get_kind () == AST::Module::UNLOADED)
+    module.load_items ();
+
   scoped (module.get_node_id (), [&module, this] () {
     for (auto &item : module.get_items ())
       item->accept_vis (*this);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-14 11:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 11:44 [gcc/devel/rust/master] enr: Fetch module items during early name resolution Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).