Rollup merge of #40311 - nrc:save-proc-macro-attr, r=jseyfried
Expect macro defs in save-analysis and add expn info to spans for att… …r proc macros r? @jseyfried
This commit is contained in:
commit
755877dbfd
|
@ -327,6 +327,9 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||||
scope: scope
|
scope: scope
|
||||||
}.lower(self.tcx));
|
}.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::Local(..) |
|
||||||
Def::Upvar(..) |
|
Def::Upvar(..) |
|
||||||
Def::SelfTy(..) |
|
Def::SelfTy(..) |
|
||||||
|
@ -336,7 +339,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||||
Def::AssociatedTy(..) |
|
Def::AssociatedTy(..) |
|
||||||
Def::AssociatedConst(..) |
|
Def::AssociatedConst(..) |
|
||||||
Def::PrimTy(_) |
|
Def::PrimTy(_) |
|
||||||
Def::Macro(..) |
|
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
span_bug!(span,
|
span_bug!(span,
|
||||||
"process_def_kind for unexpected item: {:?}",
|
"process_def_kind for unexpected item: {:?}",
|
||||||
|
|
|
@ -464,8 +464,20 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
let attr_toks = stream_for_attr_args(&attr, &self.cx.parse_sess);
|
let attr_toks = stream_for_attr_args(&attr, &self.cx.parse_sess);
|
||||||
let item_toks = stream_for_item(&item, &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);
|
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(..) => {
|
SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => {
|
||||||
self.cx.span_err(attr.span, &format!("`{}` is a derive mode", name));
|
self.cx.span_err(attr.span, &format!("`{}` is a derive mode", name));
|
||||||
|
|
Loading…
Reference in New Issue