use Destination::*;
-use rustc_lint_defs::FutureBreakage;
use rustc_span::source_map::SourceMap;
use rustc_span::{MultiSpan, SourceFile, Span};
/// other formats can, and will, simply ignore it.
fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
- fn emit_future_breakage_report(&mut self, _diags: Vec<(FutureBreakage, Diagnostic)>) {}
+ fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
/// Emit list of unused externs
fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {}
// are some which do actually involve macros.
ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
- ExpnKind::Macro { kind: macro_kind, name, proc_macro: _ } => {
- Some((macro_kind, name))
- }
+ ExpnKind::Macro(macro_kind, name) => Some((macro_kind, name)),
}
});
continue;
}
- if matches!(trace.kind, ExpnKind::Inlined) {
- new_labels
- .push((trace.call_site, "in the inlined copy of this code".to_string()));
- } else if always_backtrace {
- let proc_macro = if let ExpnKind::Macro { kind: _, name: _, proc_macro: true } =
- trace.kind
- {
- "procedural macro "
- } else {
- ""
- };
-
+ if always_backtrace && !matches!(trace.kind, ExpnKind::Inlined) {
new_labels.push((
trace.def_site,
format!(
- "in this expansion of {}`{}`{}",
- proc_macro,
+ "in this expansion of `{}`{}",
trace.kind.descr(),
if macro_backtrace.len() > 1 {
// if macro_backtrace.len() == 1 it'll be
// and it needs an "in this macro invocation" label to match that.
let redundant_span = trace.call_site.contains(sp);
- if !redundant_span
- && matches!(
- trace.kind,
- ExpnKind::Macro { kind: MacroKind::Bang, name: _, proc_macro: _ }
- )
- || always_backtrace
- {
+ if !redundant_span || always_backtrace {
+ let msg: Cow<'static, _> = match trace.kind {
+ ExpnKind::Macro(MacroKind::Attr, _) => {
+ "this procedural macro expansion".into()
+ }
+ ExpnKind::Macro(MacroKind::Derive, _) => {
+ "this derive macro expansion".into()
+ }
+ ExpnKind::Macro(MacroKind::Bang, _) => "this macro invocation".into(),
+ ExpnKind::Inlined => "the inlined copy of this code".into(),
+ ExpnKind::Root => "in the crate root".into(),
+ ExpnKind::AstPass(kind) => kind.descr().into(),
+ ExpnKind::Desugaring(kind) => {
+ format!("this {} desugaring", kind.descr()).into()
+ }
+ };
new_labels.push((
trace.call_site,
format!(
- "in this macro invocation{}",
+ "in {}{}",
+ msg,
if macro_backtrace.len() > 1 && always_backtrace {
// only specify order when the macro
// backtrace is multiple levels deep