@@ -94,11 +94,11 @@ impl AttributeExt for Attribute {
9494 }
9595
9696 /// For a single-segment attribute, returns its name; otherwise, returns `None`.
97- fn ident ( & self ) -> Option < Ident > {
97+ fn name ( & self ) -> Option < Symbol > {
9898 match & self . kind {
9999 AttrKind :: Normal ( normal) => {
100100 if let [ ident] = & * normal. item . path . segments {
101- Some ( ident. ident )
101+ Some ( ident. ident . name )
102102 } else {
103103 None
104104 }
@@ -107,9 +107,11 @@ impl AttributeExt for Attribute {
107107 }
108108 }
109109
110- fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > {
110+ fn symbol_path ( & self ) -> Option < SmallVec < [ Symbol ; 1 ] > > {
111111 match & self . kind {
112- AttrKind :: Normal ( p) => Some ( p. item . path . segments . iter ( ) . map ( |i| i. ident ) . collect ( ) ) ,
112+ AttrKind :: Normal ( p) => {
113+ Some ( p. item . path . segments . iter ( ) . map ( |i| i. ident . name ) . collect ( ) )
114+ }
113115 AttrKind :: DocComment ( _, _) => None ,
114116 }
115117 }
@@ -752,9 +754,7 @@ pub trait AttributeExt: Debug {
752754
753755 /// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
754756 /// return the name of the attribute; otherwise, returns `None`.
755- fn name ( & self ) -> Option < Symbol > {
756- self . ident ( ) . map ( |ident| ident. name )
757- }
757+ fn name ( & self ) -> Option < Symbol > ;
758758
759759 /// Get the meta item list, `#[attr(meta item list)]`
760760 fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > ;
@@ -765,9 +765,6 @@ pub trait AttributeExt: Debug {
765765 /// Gets the span of the value literal, as string, when using `#[attr = value]`
766766 fn value_span ( & self ) -> Option < Span > ;
767767
768- /// For a single-segment attribute, returns its ident; otherwise, returns `None`.
769- fn ident ( & self ) -> Option < Ident > ;
770-
771768 /// Checks whether the path of this attribute matches the name.
772769 ///
773770 /// Matches one segment of the path to each element in `name`
@@ -780,7 +777,7 @@ pub trait AttributeExt: Debug {
780777
781778 #[ inline]
782779 fn has_name ( & self , name : Symbol ) -> bool {
783- self . ident ( ) . map ( |x| x. name == name) . unwrap_or ( false )
780+ self . name ( ) . map ( |x| x == name) . unwrap_or ( false )
784781 }
785782
786783 #[ inline]
@@ -794,13 +791,11 @@ pub trait AttributeExt: Debug {
794791 fn is_word ( & self ) -> bool ;
795792
796793 fn path ( & self ) -> SmallVec < [ Symbol ; 1 ] > {
797- self . ident_path ( )
798- . map ( |i| i. into_iter ( ) . map ( |i| i. name ) . collect ( ) )
799- . unwrap_or ( smallvec ! [ sym:: doc] )
794+ self . symbol_path ( ) . unwrap_or ( smallvec ! [ sym:: doc] )
800795 }
801796
802797 /// Returns None for doc comments
803- fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > ;
798+ fn symbol_path ( & self ) -> Option < SmallVec < [ Symbol ; 1 ] > > ;
804799
805800 /// Returns the documentation if this is a doc comment or a sugared doc comment.
806801 /// * `///doc` returns `Some("doc")`.
@@ -855,10 +850,6 @@ impl Attribute {
855850 AttributeExt :: value_span ( self )
856851 }
857852
858- pub fn ident ( & self ) -> Option < Ident > {
859- AttributeExt :: ident ( self )
860- }
861-
862853 pub fn path_matches ( & self , name : & [ Symbol ] ) -> bool {
863854 AttributeExt :: path_matches ( self , name)
864855 }
@@ -890,10 +881,6 @@ impl Attribute {
890881 AttributeExt :: path ( self )
891882 }
892883
893- pub fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > {
894- AttributeExt :: ident_path ( self )
895- }
896-
897884 pub fn doc_str ( & self ) -> Option < Symbol > {
898885 AttributeExt :: doc_str ( self )
899886 }
0 commit comments