From 56207b8fafac6f6697751084f0914e1dbc0381ce Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Sun, 2 Apr 2023 19:01:52 +0100 Subject: [PATCH] Skip help messages if macro span is from macro --- compiler/rustc_resolve/src/macros.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 39e30767da27..b595dc068018 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();