]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Load unloaded modules during toplevel resolution 2.0
authorOwen Avery <powerboat9.gamer@gmail.com>
Wed, 16 Oct 2024 02:24:29 +0000 (22:24 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:18 +0000 (15:32 +0100)
This may load conditionally compiled modules too eagerly.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Load unloaded modules before attempting to
visit their items.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove issue-1089.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
gcc/testsuite/rust/compile/nr2/exclude

index 92a115108e6c1bbb6f221f4c4bff569ff966b698..c9d51039f0ee41714f727a861c33ff262e8cb859 100644 (file)
@@ -76,6 +76,17 @@ TopLevel::visit (AST::Module &module)
 {
   insert_or_error_out (module.get_name (), module, Namespace::Types);
 
+  // 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
+  // TODO: make sure this is right
+  // TODO: avoid loading items if cfg attributes are present?
+  //       might not be needed if this runs after early resolution?
+  // This was copied from the old early resolver method
+  // 'accumulate_escaped_macros'
+  if (module.get_kind () == AST::Module::UNLOADED)
+    module.load_items ();
+
   auto sub_visitor = [this, &module] () {
     for (auto &item : module.get_items ())
       item->accept_vis (*this);
index f91cf3132c790a9a14d0bceafc79dc9ffd01d158..a698164fbd5646dbf78c95089faf75401f359869 100644 (file)
@@ -62,7 +62,6 @@ infer-crate-name.rs
 issue-1019.rs
 issue-1031.rs
 issue-1034.rs
-issue-1089.rs
 issue-1128.rs
 issue-1129-2.rs
 issue-1130.rs