Skip to content

Commit 63f9273

Browse files
committed
Fix macro call site spans
1 parent 97e3a24 commit 63f9273

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/libsyntax/ext/base.rs

-16
Original file line numberDiff line numberDiff line change
@@ -602,22 +602,6 @@ impl<'a> ExtCtxt<'a> {
602602
}
603603
pub fn backtrace(&self) -> ExpnId { self.backtrace }
604604

605-
/// Original span that caused the current exapnsion to happen.
606-
pub fn original_span(&self) -> Span {
607-
let mut expn_id = self.backtrace;
608-
let mut call_site = None;
609-
loop {
610-
match self.codemap().with_expn_info(expn_id, |ei| ei.map(|ei| ei.call_site)) {
611-
None => break,
612-
Some(cs) => {
613-
call_site = Some(cs);
614-
expn_id = cs.expn_id;
615-
}
616-
}
617-
}
618-
call_site.expect("missing expansion backtrace")
619-
}
620-
621605
/// Returns span for the macro which originally caused the current expansion to happen.
622606
///
623607
/// Stops backtracing at include! boundary.

src/libsyntax/ext/expand.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
215215
return None;
216216
};
217217

218+
let call_site = fld.new_span(call_site);
218219
let ident = ident.unwrap_or(keywords::Invalid.ident());
219220
match *extension {
220221
NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
@@ -234,14 +235,8 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
234235
},
235236
});
236237

237-
// The span that we pass to the expanders we want to
238-
// be the root of the call stack. That's the most
239-
// relevant span and it's the actual invocation of
240-
// the macro.
241-
let mac_span = fld.cx.original_span();
242-
243238
let marked_tts = mark_tts(&tts[..], mark);
244-
Some(expandfun.expand(fld.cx, mac_span, &marked_tts))
239+
Some(expandfun.expand(fld.cx, call_site, &marked_tts))
245240
}
246241

247242
IdentTT(ref expander, tt_span, allow_internal_unstable) => {

0 commit comments

Comments
 (0)