@@ -235,34 +235,6 @@ impl AttributeExt for Attribute {
235235 }
236236 }
237237
238- fn deprecation_note ( & self ) -> Option < Ident > {
239- match & self . kind {
240- AttrKind :: Normal ( normal) if normal. item . path == sym:: deprecated => {
241- let meta = & normal. item ;
242-
243- // #[deprecated = "..."]
244- if let Some ( s) = meta. value_str ( ) {
245- return Some ( Ident { name : s, span : meta. span ( ) } ) ;
246- }
247-
248- // #[deprecated(note = "...")]
249- if let Some ( list) = meta. meta_item_list ( ) {
250- for nested in list {
251- if let Some ( mi) = nested. meta_item ( )
252- && mi. path == sym:: note
253- && let Some ( s) = mi. value_str ( )
254- {
255- return Some ( Ident { name : s, span : mi. span } ) ;
256- }
257- }
258- }
259-
260- None
261- }
262- _ => None ,
263- }
264- }
265-
266238 fn doc_resolution_scope ( & self ) -> Option < AttrStyle > {
267239 match & self . kind {
268240 AttrKind :: DocComment ( ..) => Some ( self . style ) ,
@@ -341,6 +313,34 @@ impl Attribute {
341313 ) ] ,
342314 }
343315 }
316+
317+ pub fn deprecation_note ( & self ) -> Option < Ident > {
318+ match & self . kind {
319+ AttrKind :: Normal ( normal) if normal. item . path == sym:: deprecated => {
320+ let meta = & normal. item ;
321+
322+ // #[deprecated = "..."]
323+ if let Some ( s) = meta. value_str ( ) {
324+ return Some ( Ident { name : s, span : meta. span ( ) } ) ;
325+ }
326+
327+ // #[deprecated(note = "...")]
328+ if let Some ( list) = meta. meta_item_list ( ) {
329+ for nested in list {
330+ if let Some ( mi) = nested. meta_item ( )
331+ && mi. path == sym:: note
332+ && let Some ( s) = mi. value_str ( )
333+ {
334+ return Some ( Ident { name : s, span : mi. span } ) ;
335+ }
336+ }
337+ }
338+
339+ None
340+ }
341+ _ => None ,
342+ }
343+ }
344344}
345345
346346impl AttrItem {
@@ -824,19 +824,19 @@ pub fn mk_attr_name_value_str(
824824 mk_attr ( g, style, unsafety, path, args, span)
825825}
826826
827- pub fn filter_by_name < A : AttributeExt > ( attrs : & [ A ] , name : Symbol ) -> impl Iterator < Item = & A > {
827+ pub fn filter_by_name ( attrs : & [ Attribute ] , name : Symbol ) -> impl Iterator < Item = & Attribute > {
828828 attrs. iter ( ) . filter ( move |attr| attr. has_name ( name) )
829829}
830830
831- pub fn find_by_name < A : AttributeExt > ( attrs : & [ A ] , name : Symbol ) -> Option < & A > {
831+ pub fn find_by_name ( attrs : & [ Attribute ] , name : Symbol ) -> Option < & Attribute > {
832832 filter_by_name ( attrs, name) . next ( )
833833}
834834
835- pub fn first_attr_value_str_by_name ( attrs : & [ impl AttributeExt ] , name : Symbol ) -> Option < Symbol > {
835+ pub fn first_attr_value_str_by_name ( attrs : & [ Attribute ] , name : Symbol ) -> Option < Symbol > {
836836 find_by_name ( attrs, name) . and_then ( |attr| attr. value_str ( ) )
837837}
838838
839- pub fn contains_name ( attrs : & [ impl AttributeExt ] , name : Symbol ) -> bool {
839+ pub fn contains_name ( attrs : & [ Attribute ] , name : Symbol ) -> bool {
840840 find_by_name ( attrs, name) . is_some ( )
841841}
842842
@@ -911,11 +911,6 @@ pub trait AttributeExt: Debug {
911911 /// * `#[doc(...)]` returns `None`.
912912 fn doc_str ( & self ) -> Option < Symbol > ;
913913
914- /// Returns the deprecation note if this is deprecation attribute.
915- /// * `#[deprecated = "note"]` returns `Some("note")`.
916- /// * `#[deprecated(note = "note", ...)]` returns `Some("note")`.
917- fn deprecation_note ( & self ) -> Option < Ident > ;
918-
919914 /// Returns whether this attribute is any of the proc macro attributes.
920915 /// i.e. `proc_macro`, `proc_macro_attribute` or `proc_macro_derive`.
921916 fn is_proc_macro_attr ( & self ) -> bool {
0 commit comments