Skip to content

Commit

Permalink
nr2.0: Implement macro_use for modules
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc:
	Include rust-attribute-values.h.
	(Early::visit): If a module has a macro_use attribute, avoid
	pushing a new textual macro scope.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 committed Feb 24, 2025
1 parent 1361615 commit ae1e1b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 16 additions & 2 deletions gcc/rust/resolve/rust-early-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "rust-toplevel-name-resolver-2.0.h"
#include "rust-attributes.h"
#include "rust-finalize-imports-2.0.h"
#include "rust-attribute-values.h"

namespace Rust {
namespace Resolver2_0 {
Expand Down Expand Up @@ -227,11 +228,24 @@ Early::visit (AST::BlockExpr &block)
void
Early::visit (AST::Module &module)
{
textual_scope.push ();
bool is_macro_use = false;

for (const auto &attr : module.get_outer_attrs ())
{
if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE)
{
is_macro_use = true;
break;
}
}

if (!is_macro_use)
textual_scope.push ();

DefaultResolver::visit (module);

textual_scope.pop ();
if (!is_macro_use)
textual_scope.pop ();
}

void
Expand Down
3 changes: 0 additions & 3 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ lookup_err1.rs
macros/mbe/macro43.rs
macros/mbe/macro44.rs
macros/mbe/macro6.rs
macros/mbe/macro_use1.rs
method2.rs
multiple_bindings1.rs
multiple_bindings2.rs
nested_macro_use1.rs
nested_macro_use2.rs
nested_macro_use3.rs
not_find_value_in_scope.rs
privacy5.rs
privacy8.rs
Expand Down

0 comments on commit ae1e1b9

Please sign in to comment.