@@ -96,11 +96,11 @@ impl AttributeExt for Attribute {
9696 }
9797
9898 /// For a single-segment attribute, returns its name; otherwise, returns `None`.
99- fn ident ( & self ) -> Option < Ident > {
99+ fn name ( & self ) -> Option < Symbol > {
100100 match & self . kind {
101101 AttrKind :: Normal ( normal) => {
102102 if let [ ident] = & * normal. item . path . segments {
103- Some ( ident. ident )
103+ Some ( ident. ident . name )
104104 } else {
105105 None
106106 }
@@ -109,9 +109,18 @@ impl AttributeExt for Attribute {
109109 }
110110 }
111111
112- fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > {
112+ fn symbol_path ( & self ) -> Option < SmallVec < [ Symbol ; 1 ] > > {
113113 match & self . kind {
114- AttrKind :: Normal ( p) => Some ( p. item . path . segments . iter ( ) . map ( |i| i. ident ) . collect ( ) ) ,
114+ AttrKind :: Normal ( p) => {
115+ Some ( p. item . path . segments . iter ( ) . map ( |i| i. ident . name ) . collect ( ) )
116+ }
117+ AttrKind :: DocComment ( _, _) => None ,
118+ }
119+ }
120+
121+ fn path_span ( & self ) -> Option < Span > {
122+ match & self . kind {
123+ AttrKind :: Normal ( attr) => Some ( attr. item . path . span ) ,
115124 AttrKind :: DocComment ( _, _) => None ,
116125 }
117126 }
@@ -797,9 +806,7 @@ pub trait AttributeExt: Debug {
797806
798807 /// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
799808 /// return the name of the attribute; otherwise, returns `None`.
800- fn name ( & self ) -> Option < Symbol > {
801- self . ident ( ) . map ( |ident| ident. name )
802- }
809+ fn name ( & self ) -> Option < Symbol > ;
803810
804811 /// Get the meta item list, `#[attr(meta item list)]`
805812 fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > ;
@@ -810,9 +817,6 @@ pub trait AttributeExt: Debug {
810817 /// Gets the span of the value literal, as string, when using `#[attr = value]`
811818 fn value_span ( & self ) -> Option < Span > ;
812819
813- /// For a single-segment attribute, returns its ident; otherwise, returns `None`.
814- fn ident ( & self ) -> Option < Ident > ;
815-
816820 /// Checks whether the path of this attribute matches the name.
817821 ///
818822 /// Matches one segment of the path to each element in `name`
@@ -825,7 +829,7 @@ pub trait AttributeExt: Debug {
825829
826830 #[ inline]
827831 fn has_name ( & self , name : Symbol ) -> bool {
828- self . ident ( ) . map ( |x| x. name == name) . unwrap_or ( false )
832+ self . name ( ) . map ( |x| x == name) . unwrap_or ( false )
829833 }
830834
831835 #[ inline]
@@ -839,13 +843,13 @@ pub trait AttributeExt: Debug {
839843 fn is_word ( & self ) -> bool ;
840844
841845 fn path ( & self ) -> SmallVec < [ Symbol ; 1 ] > {
842- self . ident_path ( )
843- . map ( |i| i. into_iter ( ) . map ( |i| i. name ) . collect ( ) )
844- . unwrap_or ( smallvec ! [ sym:: doc] )
846+ self . symbol_path ( ) . unwrap_or ( smallvec ! [ sym:: doc] )
845847 }
846848
849+ fn path_span ( & self ) -> Option < Span > ;
850+
847851 /// Returns None for doc comments
848- fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > ;
852+ fn symbol_path ( & self ) -> Option < SmallVec < [ Symbol ; 1 ] > > ;
849853
850854 /// Returns the documentation if this is a doc comment or a sugared doc comment.
851855 /// * `///doc` returns `Some("doc")`.
@@ -906,10 +910,6 @@ impl Attribute {
906910 AttributeExt :: value_span ( self )
907911 }
908912
909- pub fn ident ( & self ) -> Option < Ident > {
910- AttributeExt :: ident ( self )
911- }
912-
913913 pub fn path_matches ( & self , name : & [ Symbol ] ) -> bool {
914914 AttributeExt :: path_matches ( self , name)
915915 }
@@ -941,10 +941,6 @@ impl Attribute {
941941 AttributeExt :: path ( self )
942942 }
943943
944- pub fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > {
945- AttributeExt :: ident_path ( self )
946- }
947-
948944 pub fn doc_str ( & self ) -> Option < Symbol > {
949945 AttributeExt :: doc_str ( self )
950946 }
0 commit comments