From 6186edeae52a95952e7da16a1f66d7352287427e Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Tue, 5 Nov 2019 23:49:46 +0000 Subject: [PATCH] Use source_callee().is_some() to detect macros macro_backtrace() allocates a vector, whereas source_callee() doesn't but indicates the same thing. Suggested by @estebank --- src/librustc_passes/dead.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index 888351c61324..2aeec029cc33 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -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,