Skip to content

Commit 6186ede

Browse files
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
1 parent 15ccad3 commit 6186ede

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc_passes/dead.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,15 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
579579
hir::ItemKind::Trait(..) |
580580
hir::ItemKind::Impl(..) => {
581581
// FIXME(66095): Because item.span is annotated with things
582-
// like a macro_backtrace, and ident.span isn't, we use the
582+
// like expansion data, and ident.span isn't, we use the
583583
// def_span method if it's part of a macro invocation
584+
// (and thus has asource_callee set).
584585
// We should probably annotate ident.span with the macro
585586
// context, but that's a larger change.
586-
if item.span.macro_backtrace().len() == 0 {
587-
item.ident.span
588-
} else {
587+
if item.span.source_callee().is_some() {
589588
self.tcx.sess.source_map().def_span(item.span)
589+
} else {
590+
item.ident.span
590591
}
591592
},
592593
_ => item.span,

0 commit comments

Comments
 (0)