Skip to content

Commit

Permalink
Fix macro call site spans
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed May 28, 2016
1 parent 8b012ed commit 4259fba
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
16 changes: 0 additions & 16 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,22 +602,6 @@ impl<'a> ExtCtxt<'a> {
}
pub fn backtrace(&self) -> ExpnId { self.backtrace }

/// Original span that caused the current exapnsion to happen.
pub fn original_span(&self) -> Span {
let mut expn_id = self.backtrace;
let mut call_site = None;
loop {
match self.codemap().with_expn_info(expn_id, |ei| ei.map(|ei| ei.call_site)) {
None => break,
Some(cs) => {
call_site = Some(cs);
expn_id = cs.expn_id;
}
}
}
call_site.expect("missing expansion backtrace")
}

/// Returns span for the macro which originally caused the current expansion to happen.
///
/// Stops backtracing at include! boundary.
Expand Down
8 changes: 1 addition & 7 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,8 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
},
});

// The span that we pass to the expanders we want to
// be the root of the call stack. That's the most
// relevant span and it's the actual invocation of
// the macro.
let mac_span = fld.cx.original_span();

let marked_tts = mark_tts(&tts[..], mark);
Some(expandfun.expand(fld.cx, mac_span, &marked_tts))
Some(expandfun.expand(fld.cx, call_site, &marked_tts))
}

IdentTT(ref expander, tt_span, allow_internal_unstable) => {
Expand Down

0 comments on commit 4259fba

Please sign in to comment.