diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-15 18:27:28 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2015-01-05 11:38:12 -0800 |
| commit | ad7c64777380a780b42028855ad0d09932a11623 (patch) | |
| tree | e07587239681150b7c9a9d4464411d18eed31714 /src/libsyntax/ext/expand.rs | |
| parent | 5e5924b79915326d81db2aebfe73d2a20b8506f1 (diff) | |
| download | rust-ad7c64777380a780b42028855ad0d09932a11623.tar.gz rust-ad7c64777380a780b42028855ad0d09932a11623.zip | |
Add a special macro nonterminal $crate
Diffstat (limited to 'src/libsyntax/ext/expand.rs')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a1a13f23064..325d8aa594a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -432,7 +432,7 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) } let mut new_items = match it.node { - ast::ItemMac(..) => expand_item_mac(it, fld), + ast::ItemMac(..) => expand_item_mac(it, None, fld), ast::ItemMod(_) | ast::ItemForeignMod(_) => { let valid_ident = it.ident.name != parse::token::special_idents::invalid.name; @@ -529,8 +529,9 @@ fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool { // Support for item-position macro invocations, exactly the same // logic as for expression-position macro invocations. -pub fn expand_item_mac(it: P<ast::Item>, fld: &mut MacroExpander) - -> SmallVector<P<ast::Item>> { +pub fn expand_item_mac(it: P<ast::Item>, + imported_from: Option<ast::Ident>, + fld: &mut MacroExpander) -> SmallVector<P<ast::Item>> { let (extname, path_span, tts) = match it.node { ItemMac(codemap::Spanned { node: MacInvocTT(ref pth, ref tts, _), @@ -611,7 +612,8 @@ pub fn expand_item_mac(it: P<ast::Item>, fld: &mut MacroExpander) }); // DON'T mark before expansion. let MacroDef { name, ext } - = macro_rules::add_new_extension(fld.cx, it.span, it.ident, tts); + = macro_rules::add_new_extension(fld.cx, it.span, it.ident, + imported_from, tts); fld.cx.syntax_env.insert(intern(name.as_slice()), ext); if attr::contains_name(it.attrs.as_slice(), "macro_export") { @@ -1190,7 +1192,7 @@ pub fn expand_crate(parse_sess: &parse::ParseSess, expander.cx.cfg(), expander.cx.parse_sess()) .expect("expected a serialized item"); - expand_item_mac(item, &mut expander); + expand_item_mac(item, Some(crate_name), &mut expander); } } |
