diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 0f34977c93d2..ea3a2924d477 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -15,8 +15,8 @@ use crate::context::{AcceptContext, FinalizeContext, Stage}; use crate::errors::{ DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, - DocAutoCfgHideShowUnexpectedItem, DocUnknownInclude, DocUnknownPasses, DocUnknownPlugins, - DocUnknownSpotlight, IllFormedAttributeInput, + DocAutoCfgHideShowUnexpectedItem, DocUnknownAny, DocUnknownInclude, DocUnknownPasses, + DocUnknownPlugins, DocUnknownSpotlight, IllFormedAttributeInput, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ @@ -660,18 +660,19 @@ macro_rules! string_arg_and_crate_level { ); } Some(name) => { - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::DocUnknownAny { name }, + move |dcx, level| DocUnknownAny { name }.into_diag(dcx, level), path.span(), ); } None => { let full_name = path.segments().map(|s| s.as_str()).intersperse("::").collect::(); - cx.emit_lint( + let name = Symbol::intern(&full_name); + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::DocUnknownAny { name: Symbol::intern(&full_name) }, + move |dcx, level| DocUnknownAny { name }.into_diag(dcx, level), path.span(), ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 023ecf610666..dbbeacb5f1e4 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -242,3 +242,9 @@ pub(crate) struct DocUnknownPlugins { #[label("no longer functions")] pub label_span: Span, } + +#[derive(Diagnostic)] +#[diag("unknown `doc` attribute `{$name}`")] +pub(crate) struct DocUnknownAny { + pub name: Symbol, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 779b4ca4ab16..b1c75d0134d5 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::DocUnknownAny { name } => { - lints::DocUnknownAny { name }.into_diag(dcx, level) - } - &AttributeLintKind::DocAutoCfgWrongLiteral => { lints::DocAutoCfgWrongLiteral.into_diag(dcx, level) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index ac6fbcfdf518..52403cc895dd 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("unknown `doc` attribute `{$name}`")] -pub(crate) struct DocUnknownAny { - pub name: Symbol, -} - #[derive(Diagnostic)] #[diag("expected boolean for `#[doc(auto_cfg = ...)]`")] pub(crate) struct DocAutoCfgWrongLiteral; diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 8aadcbbd86ce..cf26f8323341 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)>), - DocUnknownAny { name: Symbol }, DocAutoCfgWrongLiteral, DocTestTakesList, DocTestUnknown { name: Symbol },