summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-12 09:58:53 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-12 09:58:53 +0800
commit19d4cd58c3ba07dd4bce84dc7c94eafb20b6a2ff (patch)
tree6fbae7bbd925dd5c9875a8e421e99a60ead7b402
parent0fa2625893c0d45a702dac9457d8869fdbbab8ac (diff)
downloadmrust-19d4cd58c3ba07dd4bce84dc7c94eafb20b6a2ff.tar.gz
Expand - macro_use with ident list
-rw-r--r--src/expand/macro_rules.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp
index bd9348e5..d5423cb4 100644
--- a/src/expand/macro_rules.cpp
+++ b/src/expand/macro_rules.cpp
@@ -38,7 +38,29 @@ class CMacroUseHandler:
if( mi.has_sub_items() )
{
- throw ::std::runtime_error("TODO: #[macro_use]");
+ for( const auto& si : mi.items() )
+ {
+ const auto& name = si.name();
+ for( const auto& mr : submod.macros() )
+ {
+ if( mr.name == name ) {
+ DEBUG("Imported " << mr.name);
+ mod.add_macro_import( mr.name, mr.data );
+ goto _good;
+ }
+ }
+ for( const auto& mri : submod.macro_imports_res() )
+ {
+ if( mri.name == name ) {
+ DEBUG("Imported " << mri.name << " (propagate)");
+ mod.add_macro_import( mri.name, *mri.data );
+ goto _good;
+ }
+ }
+ ERROR(Span(), E0000, "Couldn't find macro " << name);
+ _good:
+ (void)0;
+ }
}
else
{