Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions gcc/rust/expand/rust-cfg-strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1765,16 +1765,17 @@ CfgStrip::visit (AST::Module &module)
return;
}

// A loaded module might have inner attributes
if (module.get_kind () == AST::Module::ModuleKind::LOADED)
if (module.get_kind () == AST::Module::UNLOADED)
{
// strip test based on inner attrs
expand_cfg_attrs (module.get_inner_attrs ());
if (fails_cfg_with_expand (module.get_inner_attrs ()))
{
module.mark_for_strip ();
return;
}
module.load_items ();
}

// strip test based on inner attrs
expand_cfg_attrs (module.get_inner_attrs ());
if (fails_cfg_with_expand (module.get_inner_attrs ()))
{
module.mark_for_strip ();
return;
}

// strip items if required
Expand Down
21 changes: 0 additions & 21 deletions gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,6 @@ TopLevel::go (AST::Crate &crate)
void
TopLevel::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
// 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 ();

// If the module was previously unloaded, then we don't want to visit it
// this time around as the CfgStrip hasn't run on its inner items yet.
// Skip it for now, mark the visitor as dirty and try again

dirty = true;

return;
}

DefaultResolver::visit (module);

if (Analysis::Mappings::get ().lookup_ast_module (module.get_node_id ())
Expand Down
Loading