From ace320fba3df37d7d33aefb80bb7734971bf3264 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Apr 2026 00:50:55 +0200 Subject: [PATCH] Remove `AttributeLintKind::AmbiguousDeriveHelpers` variant --- .../rustc_attr_parsing/src/attributes/proc_macro_attrs.rs | 6 +++--- compiler/rustc_attr_parsing/src/errors.rs | 4 ++++ compiler/rustc_lint/src/early/diagnostics.rs | 4 ---- compiler/rustc_lint/src/lints.rs | 4 ---- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs index 7cb59856b8a2..76dc171c6831 100644 --- a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs @@ -1,4 +1,4 @@ -use rustc_hir::lints::AttributeLintKind; +use rustc_errors::Diagnostic; use rustc_session::lint::builtin::AMBIGUOUS_DERIVE_HELPERS; use super::prelude::*; @@ -125,9 +125,9 @@ fn parse_derive_like( return None; } if rustc_feature::is_builtin_attr_name(ident.name) { - cx.emit_lint( + cx.emit_dyn_lint( AMBIGUOUS_DERIVE_HELPERS, - AttributeLintKind::AmbiguousDeriveHelpers, + |dcx, level| crate::errors::AmbiguousDeriveHelpers.into_diag(dcx, level), ident.span, ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 8148a859958b..24cff14e17d8 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -177,3 +177,7 @@ pub(crate) struct DocAliasDuplicated { #[derive(Diagnostic)] #[diag("only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]`")] pub(crate) struct DocAutoCfgExpectsHideOrShow; + +#[derive(Diagnostic)] +#[diag("there exists a built-in attribute with the same name")] +pub(crate) struct AmbiguousDeriveHelpers; diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index fb59cd35ad46..24ddef1c14eb 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,10 +43,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { .into_diag(dcx, level) } - &AttributeLintKind::AmbiguousDeriveHelpers => { - lints::AmbiguousDeriveHelpers.into_diag(dcx, level) - } - &AttributeLintKind::DocAutoCfgHideShowUnexpectedItem { attr_name } => { lints::DocAutoCfgHideShowUnexpectedItem { attr_name }.into_diag(dcx, level) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index b92efc408ae8..93f32104bcf1 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3303,10 +3303,6 @@ fn add_to_diag(self, diag: &mut Diag<'_, G>) { )] pub(crate) struct ExpectedNameValue; -#[derive(Diagnostic)] -#[diag("there exists a built-in attribute with the same name")] -pub(crate) struct AmbiguousDeriveHelpers; - #[derive(Diagnostic)] #[diag("`#![doc(auto_cfg({$attr_name}(...)))]` only accepts identifiers or key/value items")] pub(crate) struct DocAutoCfgHideShowUnexpectedItem { diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 29da46770d52..24991ac03e98 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -659,7 +659,6 @@ pub enum AttributeLintKind { DocAutoCfgHideShowUnexpectedItem { attr_name: Symbol }, DocAutoCfgHideShowExpectsList { attr_name: Symbol }, DocInvalid, - AmbiguousDeriveHelpers, DocUnknownInclude { span: Span, inner: &'static str, value: Symbol }, DocUnknownSpotlight { span: Span }, DocUnknownPasses { name: Symbol, span: Span },