diff options
| author | Tom Martin <tom.martin1239@gmail.com> | 2023-04-02 19:01:52 +0100 |
|---|---|---|
| committer | Tom Martin <tom.martin1239@gmail.com> | 2023-04-02 19:01:52 +0100 |
| commit | 56207b8fafac6f6697751084f0914e1dbc0381ce (patch) | |
| tree | b24bc75a4eee793098e5c69fc3632b4067c17f97 | |
| parent | 86230dcde6f68e049c0eb67e805d410fe0872422 (diff) | |
| download | rust-56207b8fafac6f6697751084f0914e1dbc0381ce.tar.gz rust-56207b8fafac6f6697751084f0914e1dbc0381ce.zip | |
Skip help messages if macro span is from macro
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 39e30767da2..b595dc06801 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -548,10 +548,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { err.span_label(path.span, format!("not {} {}", article, expected)); - if kind == MacroKind::Derive && ext.macro_kind() != MacroKind::Derive { + if !path.span.from_expansion() { // Suggest moving the macro out of the derive() as the macro isn't Derive - err.span_help(path.span, "Remove from the surrounding `derive()`"); - err.help(format!("Add as non-Derive macro\n`#[{}]`", path_str)); + if kind == MacroKind::Derive && ext.macro_kind() != MacroKind::Derive { + err.span_help(path.span, "Remove from the surrounding `derive()`"); + err.help(format!("Add as non-Derive macro\n`#[{}]`", path_str)); + } } err.emit(); |
