Don't print the macro definition site in backtraces

This halves the backtrace length. The definition site wasn't very useful
anyways, since it may be invalid (for compiler expansions) or located in
another crate. Since the macro name is still printed, grepping for it is
still an easy way of finding the definition.
This commit is contained in:
Jonas Schievink
2015-09-10 22:25:28 +02:00
parent 49d8b0dcbe
commit 31fa44b18e
6 changed files with 21 additions and 22 deletions

View File

@@ -732,21 +732,17 @@ impl EmitterWriter {
sp_opt = try!(cm.with_expn_info(sp.expn_id, |expn_info| -> io::Result<_> {
match expn_info {
Some(ei) => {
let ss = ei.callee.span.map_or(String::new(),
|span| cm.span_to_string(span));
let (pre, post) = match ei.callee.format {
codemap::MacroAttribute(..) => ("#[", "]"),
codemap::MacroBang(..) => ("", "!"),
codemap::CompilerExpansion(..) => ("", ""),
};
try!(self.print_diagnostic(&ss, Note,
&format!("in expansion of {}{}{}",
try!(self.print_diagnostic(&cm.span_to_string(ei.call_site), Note,
&format!("in this expansion of {}{}{}",
pre,
ei.callee.name(),
post),
None));
let ss = cm.span_to_string(ei.call_site);
try!(self.print_diagnostic(&ss, Note, "expansion site", None));
Ok(Some(ei.call_site))
}
None => Ok(None)