From d50d1db7e539ee53c329afd18f4f77050a42beb3 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 17 Jun 2026 13:46:30 +0200 Subject: [PATCH] Move `UnusedDuplicate` diag struct to `rustc_attr_parsing` --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 8 ++------ compiler/rustc_attr_parsing/src/context.rs | 14 +++----------- .../rustc_attr_parsing/src/session_diagnostics.rs | 13 +++++++++++++ compiler/rustc_errors/src/lib.rs | 1 - compiler/rustc_errors/src/lints.rs | 15 --------------- 5 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 compiler/rustc_errors/src/lints.rs diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 382f0539f7678..e91ab584bcf47 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -22,7 +22,7 @@ use crate::diagnostics::{ use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ DocAliasBadChar, DocAliasEmpty, DocAliasMalformed, DocAliasStartEnd, DocAttrNotCrateLevel, - DocAttributeNotAttribute, DocKeywordNotKeyword, + DocAttributeNotAttribute, DocKeywordNotKeyword, UnusedDuplicate, }; fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) -> bool { @@ -159,11 +159,7 @@ impl DocParser { let unused_span = path.span(); cx.emit_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: true, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: true }, unused_span, ); return; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index fb5ca0375900a..2811bc8ff5683 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -71,7 +71,7 @@ use crate::parser::{ }; use crate::session_diagnostics::{ AttributeParseError, AttributeParseErrorReason, AttributeParseErrorSuggestions, - ParsedDescription, + ParsedDescription, UnusedDuplicate, }; use crate::target_checking::AllowedTargets; use crate::{AttrSuggestionStyle, AttributeParser, AttributeTemplate, EmitAttribute}; @@ -436,11 +436,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) { self.emit_lint( rustc_session::lint::builtin::UNUSED_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: false, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: false }, unused_span, ) } @@ -452,11 +448,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { ) { self.emit_lint( rustc_session::lint::builtin::UNUSED_ATTRIBUTES, - rustc_errors::lints::UnusedDuplicate { - this: unused_span, - other: used_span, - warning: true, - }, + UnusedDuplicate { this: unused_span, other: used_span, warning: true }, unused_span, ) } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index 193ffe195fb6c..d1470d870d130 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -1045,3 +1045,16 @@ pub(crate) struct AdditionalCommaSuggestion { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag("unused attribute")] +pub(crate) struct UnusedDuplicate { + #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] + pub this: Span, + #[note("attribute also specified here")] + pub other: Span, + #[warning( + "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" + )] + pub warning: bool, +} diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 76cdb10f429c7..e9bb6701c38f1 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -79,7 +79,6 @@ mod diagnostic_impls; pub mod emitter; pub mod formatting; pub mod json; -pub mod lints; mod lock; pub mod markdown; pub mod timings; diff --git a/compiler/rustc_errors/src/lints.rs b/compiler/rustc_errors/src/lints.rs deleted file mode 100644 index 9c93a09bf764c..0000000000000 --- a/compiler/rustc_errors/src/lints.rs +++ /dev/null @@ -1,15 +0,0 @@ -use rustc_macros::Diagnostic; -use rustc_span::Span; - -#[derive(Diagnostic)] -#[diag("unused attribute")] -pub struct UnusedDuplicate { - #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] - pub this: Span, - #[note("attribute also specified here")] - pub other: Span, - #[warning( - "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" - )] - pub warning: bool, -}