diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2017-03-07 17:37:45 +1300 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-03-10 08:16:21 -0800 |
| commit | 5afe784daae5782389b97f0ec1317193433ba9a2 (patch) | |
| tree | bacda16580e5cbade71bd9e641304e9597bf758b | |
| parent | f573db4f80c75f156df8a743f456bf087ec81dc2 (diff) | |
Expect macro defs in save-analysis and add expn info to spans for attr proc macros
| -rw-r--r-- | src/librustc_save_analysis/dump_visitor.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 3c275e0996d..33d5c17a419 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -327,6 +327,9 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { scope: scope }.lower(self.tcx)); } + // With macros 2.0, we can legitimately get a ref to a macro, but + // we don't handle it properly for now (FIXME). + Def::Macro(..) => {} Def::Local(..) | Def::Upvar(..) | Def::SelfTy(..) | @@ -336,7 +339,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { Def::AssociatedTy(..) | Def::AssociatedConst(..) | Def::PrimTy(_) | - Def::Macro(..) | Def::Err => { span_bug!(span, "process_def_kind for unexpected item: {:?}", diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f1662284a88..f7dcd00e409 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -464,8 +464,20 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let attr_toks = stream_for_attr_args(&attr, &self.cx.parse_sess); let item_toks = stream_for_item(&item, &self.cx.parse_sess); + let span = Span { + expn_id: self.cx.codemap().record_expansion(ExpnInfo { + call_site: attr.span, + callee: NameAndSpan { + format: MacroAttribute(name), + span: None, + allow_internal_unstable: false, + }, + }), + ..attr.span + }; + let tok_result = mac.expand(self.cx, attr.span, attr_toks, item_toks); - self.parse_expansion(tok_result, kind, name, attr.span) + self.parse_expansion(tok_result, kind, name, span) } SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => { self.cx.span_err(attr.span, &format!("`{}` is a derive mode", name)); |
