Auto merge of #38947 - nrc:custom-derive-span, r=jseyfried

Give custom derive spans an expansion ID

r? @jseyfried
This commit is contained in:
bors 2017-01-10 04:44:04 +00:00
commit 2fa9feb37a

View File

@ -235,8 +235,21 @@ pub fn expand_derive(cx: &mut ExtCtxt,
let titem = cx.meta_list_item_word(titem.span, titem.name().unwrap());
let mitem = cx.meta_list(titem.span, derive, vec![titem]);
let item = Annotatable::Item(item);
let span = Span {
expn_id: cx.codemap().record_expansion(codemap::ExpnInfo {
call_site: mitem.span,
callee: codemap::NameAndSpan {
format: codemap::MacroAttribute(Symbol::intern(&format!("derive({})", tname))),
span: None,
allow_internal_unstable: false,
},
}),
..mitem.span
};
if let SyntaxExtension::CustomDerive(ref ext) = *ext {
return ext.expand(cx, mitem.span, &mitem, item);
return ext.expand(cx, span, &mitem, item);
} else {
unreachable!()
}
@ -285,8 +298,8 @@ pub fn expand_derive(cx: &mut ExtCtxt,
expn_id: cx.codemap().record_expansion(codemap::ExpnInfo {
call_site: titem.span,
callee: codemap::NameAndSpan {
format: codemap::MacroAttribute(Symbol::intern(&format!("derive({})", tname))),
span: Some(titem.span),
format: codemap::MacroAttribute(name),
span: None,
allow_internal_unstable: true,
},
}),