summaryrefslogtreecommitdiff
path: root/src/expand/mod.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-04-13 17:11:45 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-04-13 17:11:45 +0800
commit188215b080fd7d18a1f0ba67bfc148e03ad39860 (patch)
treefbefab97ccf9eb143ce813610312cc7300baa481 /src/expand/mod.cpp
parentffaaf8047e615206e5eb27097a0b6e669f521b96 (diff)
downloadmrust-188215b080fd7d18a1f0ba67bfc148e03ad39860.tar.gz
Expand - Ordering of macro_use lookup
Diffstat (limited to 'src/expand/mod.cpp')
-rw-r--r--src/expand/mod.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp
index df0a26f2..88d16216 100644
--- a/src/expand/mod.cpp
+++ b/src/expand/mod.cpp
@@ -109,7 +109,8 @@ void Expand_Attrs(::AST::MetaItems& attrs, AttrStage stage, ::AST::Crate& crate
return e;
}
}
- // TODO: Shouldn't this use the _last_ located macro? Allowing later (local) defininitions to override it?
+ // Find the last macro of this name (allows later #[macro_use] definitions to override)
+ const MacroRules* last_mac = nullptr;
for( const auto& mri : mac_mod.macro_imports_res() )
{
//DEBUG("- " << mri.name);
@@ -118,10 +119,14 @@ void Expand_Attrs(::AST::MetaItems& attrs, AttrStage stage, ::AST::Crate& crate
if( input_ident != "" )
ERROR(mi_span, E0000, "macro_rules! macros can't take an ident");
- auto e = Macro_Invoke(name.c_str(), *mri.data, mv$(input_tt), mod);
- return e;
+ last_mac = mri.data;
}
}
+ if( last_mac )
+ {
+ auto e = Macro_Invoke(name.c_str(), *last_mac, mv$(input_tt), mod);
+ return e;
+ }
}
// Error - Unknown macro name