Show macro name in 'this error originates in macro' message

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.
This commit is contained in:
Aaron Hill 2021-02-13 14:52:25 -05:00
parent 70e52caed9
commit 0dd9f118d9
No known key found for this signature in database
GPG key ID: B4087E510E98B164
350 changed files with 744 additions and 744 deletions

View file

@ -309,8 +309,8 @@ pub trait Emitter {
// 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)
ExpnKind::Macro { kind: macro_kind, name, proc_macro: _ } => {
Some((macro_kind, name))
}
}
});
@ -322,13 +322,12 @@ pub trait Emitter {
self.render_multispans_macro_backtrace(span, children, backtrace);
if !backtrace {
if let Some(macro_kind) = has_macro_spans {
if let Some((macro_kind, name)) = has_macro_spans {
let descr = macro_kind.descr();
let msg = format!(
"this {} originates in {} {} \
"this {level} originates in the {descr} `{name}` \
(in Nightly builds, run with -Z macro-backtrace for more info)",
level,
macro_kind.article(),
macro_kind.descr(),
);
children.push(SubDiagnostic {

View file

@ -6,6 +6,7 @@
#![feature(crate_visibility_modifier)]
#![feature(backtrace)]
#![feature(extended_key_value_attributes)]
#![feature(format_args_capture)]
#![feature(iter_zip)]
#![feature(nll)]