diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2025-02-21 19:07:59 -0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-24 13:07:09 +0100 |
commit | ebc8d3c1a230b05b1cf365ca7dbec586738c38f5 (patch) | |
tree | 8bbbd84ae785c89b042c7a6759793cacc4cf81d2 /gcc | |
parent | 9724c8af49e642324b366c4cf62fca08304b2d96 (diff) | |
download | gcc-ebc8d3c1a230b05b1cf365ca7dbec586738c38f5.zip gcc-ebc8d3c1a230b05b1cf365ca7dbec586738c38f5.tar.gz gcc-ebc8d3c1a230b05b1cf365ca7dbec586738c38f5.tar.bz2 |
gccrs: Fix expansion of macros inside modules
gcc/rust/ChangeLog:
* expand/rust-expand-visitor.cc
(ExpandVisitor::visit): Override DefaultASTVisitor in order to
expand a module's items, rather than directly visit them.
* expand/rust-expand-visitor.h
(ExpandVisitor::visit): Add override.
gcc/testsuite/ChangeLog:
* rust/compile/macros/mbe/macro-expand-module.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.cc | 6 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/macros/mbe/macro-expand-module.rs | 11 |
3 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index 8ba9a15..2830d20 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -722,6 +722,12 @@ ExpandVisitor::visit (AST::TypeBoundWhereClauseItem &item) } void +ExpandVisitor::visit (AST::Module &module) +{ + expand_inner_items (module.get_items ()); +} + +void ExpandVisitor::visit (AST::ExternCrate &crate) {} diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h index 5fc1011e..ad237c0 100644 --- a/gcc/rust/expand/rust-expand-visitor.h +++ b/gcc/rust/expand/rust-expand-visitor.h @@ -237,6 +237,7 @@ public: void visit (AST::TypeParam ¶m) override; void visit (AST::LifetimeWhereClauseItem &) override; void visit (AST::TypeBoundWhereClauseItem &item) override; + void visit (AST::Module &module) override; void visit (AST::ExternCrate &crate) override; void visit (AST::UseTreeGlob &) override; void visit (AST::UseTreeList &) override; diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro-expand-module.rs b/gcc/testsuite/rust/compile/macros/mbe/macro-expand-module.rs new file mode 100644 index 0000000..e3e702e --- /dev/null +++ b/gcc/testsuite/rust/compile/macros/mbe/macro-expand-module.rs @@ -0,0 +1,11 @@ +mod foo { + macro_rules! bar { + () => () + } + + bar! (); + + pub struct S; +} + +pub fn buzz(_: foo::S) {} |