diff options
author | CohenArthur <arthur.cohen@epita.fr> | 2021-08-03 16:25:12 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@epita.fr> | 2021-08-03 17:55:23 +0200 |
commit | c4077cc2a8c9ade9bd9b61804d756fcfc2cc9931 (patch) | |
tree | 33a70ae8a1a0b4ae271e7d3f6d9db468bed9d48a /gcc | |
parent | 4a5af75e3225b413ba0bd120a1028b5f305a4cb3 (diff) | |
download | gcc-c4077cc2a8c9ade9bd9b61804d756fcfc2cc9931.zip gcc-c4077cc2a8c9ade9bd9b61804d756fcfc2cc9931.tar.gz gcc-c4077cc2a8c9ade9bd9b61804d756fcfc2cc9931.tar.bz2 |
expand: Merge both implementations for both module types
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.cc | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 28d14ba..0a25471 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -2015,7 +2015,7 @@ public: "cannot strip block expression in this position - outer " "attributes not allowed"); } - void visit (AST::ModuleBodied &module) override + void visit (AST::Module &module) override { // strip test based on outer attrs expander.expand_cfg_attrs (module.get_outer_attrs ()); @@ -2025,27 +2025,21 @@ public: return; } - // strip test based on inner attrs - expander.expand_cfg_attrs (module.get_inner_attrs ()); - if (expander.fails_cfg_with_expand (module.get_inner_attrs ())) + // A loaded module might have inner attributes + if (module.get_kind () == AST::Module::ModuleKind::LOADED) { - module.mark_for_strip (); - return; + // strip test based on inner attrs + expander.expand_cfg_attrs (module.get_inner_attrs ()); + if (expander.fails_cfg_with_expand (module.get_inner_attrs ())) + { + module.mark_for_strip (); + return; + } } // strip items if required expand_pointer_allow_strip (module.get_items ()); } - void visit (AST::ModuleNoBody &module) override - { - // strip test based on outer attrs - expander.expand_cfg_attrs (module.get_outer_attrs ()); - if (expander.fails_cfg_with_expand (module.get_outer_attrs ())) - { - module.mark_for_strip (); - return; - } - } void visit (AST::ExternCrate &crate) override { // strip test based on outer attrs |