From 7007737f1152cfae70a588a12576074ebcf5ceaa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Apr 2026 16:38:55 +0200 Subject: [PATCH] Remove `AttributeLintKind::DocUnknownPasses` variant --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 11 +++++++---- compiler/rustc_attr_parsing/src/errors.rs | 12 ++++++++++++ compiler/rustc_lint/src/early/diagnostics.rs | 4 ---- compiler/rustc_lint/src/lints.rs | 12 ------------ compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index c39424f9e75d..9341e5e02be0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -15,7 +15,7 @@ use crate::context::{AcceptContext, FinalizeContext, Stage}; use crate::errors::{ DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, - DocAutoCfgHideShowUnexpectedItem, DocUnknownInclude, DocUnknownSpotlight, + DocAutoCfgHideShowUnexpectedItem, DocUnknownInclude, DocUnknownPasses, DocUnknownSpotlight, IllFormedAttributeInput, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; @@ -642,10 +642,13 @@ macro_rules! string_arg_and_crate_level { ); } Some(name @ (sym::passes | sym::no_default_passes)) => { - cx.emit_lint( + let span = path.span(); + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::DocUnknownPasses { name, span: path.span() }, - path.span(), + move |dcx, level| { + DocUnknownPasses { name, note_span: span }.into_diag(dcx, level) + }, + span, ); } Some(sym::plugins) => { diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index eb6c5aa202ad..6b15157c4e2c 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -219,3 +219,15 @@ pub(crate) struct DocUnknownSpotlight { )] pub sugg_span: Span, } + +#[derive(Diagnostic)] +#[diag("unknown `doc` attribute `{$name}`")] +#[note( + "`doc` attribute `{$name}` no longer functions; see issue #44136 " +)] +#[note("`doc({$name})` is now a no-op")] +pub(crate) struct DocUnknownPasses { + pub name: Symbol, + #[label("no longer functions")] + pub note_span: Span, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 8d0bf5209493..686e64a48de1 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::DocUnknownPasses { name, span } => { - lints::DocUnknownPasses { name, note_span: span }.into_diag(dcx, level) - } - &AttributeLintKind::DocUnknownPlugins { span } => { lints::DocUnknownPlugins { label_span: span }.into_diag(dcx, level) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 3910e45e5ec5..08f78a36d1a5 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3303,18 +3303,6 @@ fn add_to_diag(self, diag: &mut Diag<'_, G>) { )] pub(crate) struct ExpectedNameValue; -#[derive(Diagnostic)] -#[diag("unknown `doc` attribute `{$name}`")] -#[note( - "`doc` attribute `{$name}` no longer functions; see issue #44136 " -)] -#[note("`doc({$name})` is now a no-op")] -pub(crate) struct DocUnknownPasses { - pub name: Symbol, - #[label("no longer functions")] - pub note_span: Span, -} - #[derive(Diagnostic)] #[diag("unknown `doc` attribute `plugins`")] #[note( diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 13c3b4819ae8..417e7254bb52 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)>), - DocUnknownPasses { name: Symbol, span: Span }, DocUnknownPlugins { span: Span }, DocUnknownAny { name: Symbol }, DocAutoCfgWrongLiteral,