From e3b0e9db08425cf80090a193028ef49eae9761b1 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sat, 25 Apr 2026 21:26:00 +0200 Subject: [PATCH] Remove `deprecation_note` from `AttributeExt` --- compiler/rustc_ast/src/attr/mod.rs | 28 ---------------------------- compiler/rustc_hir/src/hir.rs | 8 -------- src/librustdoc/clean/types.rs | 7 +------ 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index bb2e444c722a..0374a86d3eb1 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -235,34 +235,6 @@ fn doc_str(&self) -> Option { } } - fn deprecation_note(&self) -> Option { - match &self.kind { - AttrKind::Normal(normal) if normal.item.path == sym::deprecated => { - let meta = &normal.item; - - // #[deprecated = "..."] - if let Some(s) = meta.value_str() { - return Some(Ident { name: s, span: meta.span() }); - } - - // #[deprecated(note = "...")] - if let Some(list) = meta.meta_item_list() { - for nested in list { - if let Some(mi) = nested.meta_item() - && mi.path == sym::note - && let Some(s) = mi.value_str() - { - return Some(Ident { name: s, span: mi.span }); - } - } - } - - None - } - _ => None, - } - } - fn doc_resolution_scope(&self) -> Option { match &self.kind { AttrKind::DocComment(..) => Some(self.style), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 5608bd82fdac..60bfc5528256 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1415,14 +1415,6 @@ fn doc_str(&self) -> Option { } } - #[inline] - fn deprecation_note(&self) -> Option { - match &self { - Attribute::Parsed(AttributeKind::Deprecated { deprecation, .. }) => deprecation.note, - _ => None, - } - } - fn is_automatically_derived_attr(&self) -> bool { matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..))) } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index a1eb093d7fcf..e81c6eae1996 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -8,7 +8,6 @@ use itertools::Either; use rustc_abi::{ExternAbi, VariantIdx}; use rustc_ast as ast; -use rustc_ast::attr::AttributeExt; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::thin_vec::ThinVec; use rustc_hir as hir; @@ -501,11 +500,7 @@ pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option { } pub(crate) fn attr_span(&self, tcx: TyCtxt<'_>) -> rustc_span::Span { - let deprecation_notes = self - .attrs - .other_attrs - .iter() - .filter_map(|attr| attr.deprecation_note().map(|note| note.span)); + let deprecation_notes = find_attr!(&self.attrs.other_attrs, Deprecated { deprecation, .. } => deprecation.note.map(|note| note.span)).flatten(); span_of_fragments(&self.attrs.doc_strings) .into_iter()