Skip to content

Commit

Permalink
Load unloaded modules during toplevel resolution 2.0
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
powerboat9 committed Oct 17, 2024
1 parent 0b18bae commit c0491ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 11 additions & 0 deletions gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0491ec

Please sign in to comment.