Skip to content

Commit

Permalink
Use source_callee().is_some() to detect macros
Browse files Browse the repository at this point in the history
macro_backtrace() allocates a vector, whereas source_callee() doesn't
but indicates the same thing.  Suggested by @estebank
  • Loading branch information
Quantumplation committed Nov 5, 2019
1 parent 15ccad3 commit 6186ede
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/librustc_passes/dead.rs
Expand Up @@ -579,14 +579,15 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
hir::ItemKind::Trait(..) |
hir::ItemKind::Impl(..) => {
// FIXME(66095): Because item.span is annotated with things
// like a macro_backtrace, and ident.span isn't, we use the
// like expansion data, and ident.span isn't, we use the
// def_span method if it's part of a macro invocation
// (and thus has asource_callee set).
// We should probably annotate ident.span with the macro
// context, but that's a larger change.
if item.span.macro_backtrace().len() == 0 {
item.ident.span
} else {
if item.span.source_callee().is_some() {
self.tcx.sess.source_map().def_span(item.span)
} else {
item.ident.span
}
},
_ => item.span,
Expand Down

0 comments on commit 6186ede

Please sign in to comment.