diff options
| author | bors <bors@rust-lang.org> | 2021-07-19 18:44:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-19 18:44:27 +0000 |
| commit | d5af63480fb08b5276a608a8cd4865fa92d4b2bc (patch) | |
| tree | 4dafbbc941ca3ed032a8bdb4c90c36aeab752152 /compiler/rustc_errors | |
| parent | fad295b299d9e93950c27acd6a12026d100185fe (diff) | |
| parent | ba052bd8de1459acb6809215b0bedf4ea476ef9a (diff) | |
| download | rust-d5af63480fb08b5276a608a8cd4865fa92d4b2bc.tar.gz rust-d5af63480fb08b5276a608a8cd4865fa92d4b2bc.zip | |
Auto merge of #87225 - estebank:cleanup, r=oli-obk
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index becc1c6db5b..87272b1605b 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -365,10 +365,7 @@ pub trait Emitter { 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 { + if always_backtrace && !matches!(trace.kind, ExpnKind::Inlined) { new_labels.push(( trace.def_site, format!( @@ -398,13 +395,27 @@ pub trait Emitter { // 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(MacroKind::Bang, _)) - || 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 |
