From dacc42fb1b51f0116d95835d78b711b17e372c4e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Apr 2026 02:08:18 +0200 Subject: [PATCH] Remove `AttributeLintKind::DocAutoCfgHideShowExpectsList` variant --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 10 ++++++---- compiler/rustc_attr_parsing/src/errors.rs | 6 ++++++ compiler/rustc_lint/src/early/diagnostics.rs | 4 ---- compiler/rustc_lint/src/lints.rs | 6 ------ compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 572093b87344..ec7119828530 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -14,8 +14,8 @@ use super::{AcceptMapping, AttributeParser}; use crate::context::{AcceptContext, FinalizeContext, Stage}; use crate::errors::{ - DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowUnexpectedItem, - IllFormedAttributeInput, + DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, + DocAutoCfgHideShowUnexpectedItem, IllFormedAttributeInput, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ @@ -367,9 +367,11 @@ fn parse_auto_cfg( } }; let ArgParser::List(list) = item.args() else { - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::DocAutoCfgHideShowExpectsList { attr_name }, + move |dcx, level| { + DocAutoCfgHideShowExpectsList { attr_name }.into_diag(dcx, level) + }, item.span(), ); continue; diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 18cc59ad6955..29bd1f965f62 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -187,3 +187,9 @@ pub(crate) struct DocAliasDuplicated { pub(crate) struct DocAutoCfgHideShowUnexpectedItem { pub attr_name: Symbol, } + +#[derive(Diagnostic)] +#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items")] +pub(crate) struct DocAutoCfgHideShowExpectsList { + pub attr_name: Symbol, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 43f185f6b23c..bb88e791979d 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::DocAutoCfgHideShowExpectsList { attr_name } => { - lints::DocAutoCfgHideShowExpectsList { attr_name }.into_diag(dcx, level) - } - &AttributeLintKind::DocInvalid => lints::DocInvalid.into_diag(dcx, level), &AttributeLintKind::DocUnknownInclude { span, inner, value } => { diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 3698976fd6e6..3d98a1270cf8 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3303,12 +3303,6 @@ fn add_to_diag(self, diag: &mut Diag<'_, G>) { )] pub(crate) struct ExpectedNameValue; -#[derive(Diagnostic)] -#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items")] -pub(crate) struct DocAutoCfgHideShowExpectsList { - pub attr_name: Symbol, -} - #[derive(Diagnostic)] #[diag("invalid `doc` attribute")] pub(crate) struct DocInvalid; diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 466b9ac0deed..c0dc952a33d9 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - DocAutoCfgHideShowExpectsList { attr_name: Symbol }, DocInvalid, DocUnknownInclude { span: Span, inner: &'static str, value: Symbol }, DocUnknownSpotlight { span: Span },