@@ -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 }
@@ -794,9 +803,7 @@ pub trait AttributeExt: Debug {
794803
795804 /// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
796805 /// return the name of the attribute; otherwise, returns `None`.
797- fn name ( & self ) -> Option < Symbol > {
798- self . ident ( ) . map ( |ident| ident. name )
799- }
806+ fn name ( & self ) -> Option < Symbol > ;
800807
801808 /// Get the meta item list, `#[attr(meta item list)]`
802809 fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > ;
@@ -807,9 +814,6 @@ pub trait AttributeExt: Debug {
807814 /// Gets the span of the value literal, as string, when using `#[attr = value]`
808815 fn value_span ( & self ) -> Option < Span > ;
809816
810- /// For a single-segment attribute, returns its ident; otherwise, returns `None`.
811- fn ident ( & self ) -> Option < Ident > ;
812-
813817 /// Checks whether the path of this attribute matches the name.
814818 ///
815819 /// Matches one segment of the path to each element in `name`
@@ -822,7 +826,7 @@ pub trait AttributeExt: Debug {
822826
823827 #[ inline]
824828 fn has_name ( & self , name : Symbol ) -> bool {
825- self . ident ( ) . map ( |x| x. name == name) . unwrap_or ( false )
829+ self . name ( ) . map ( |x| x == name) . unwrap_or ( false )
826830 }
827831
828832 #[ inline]
@@ -836,13 +840,13 @@ pub trait AttributeExt: Debug {
836840 fn is_word ( & self ) -> bool ;
837841
838842 fn path ( & self ) -> SmallVec < [ Symbol ; 1 ] > {
839- self . ident_path ( )
840- . map ( |i| i. into_iter ( ) . map ( |i| i. name ) . collect ( ) )
841- . unwrap_or ( smallvec ! [ sym:: doc] )
843+ self . symbol_path ( ) . unwrap_or ( smallvec ! [ sym:: doc] )
842844 }
843845
846+ fn path_span ( & self ) -> Option < Span > ;
847+
844848 /// Returns None for doc comments
845- fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > ;
849+ fn symbol_path ( & self ) -> Option < SmallVec < [ Symbol ; 1 ] > > ;
846850
847851 /// Returns the documentation if this is a doc comment or a sugared doc comment.
848852 /// * `///doc` returns `Some("doc")`.
@@ -903,10 +907,6 @@ impl Attribute {
903907 AttributeExt :: value_span ( self )
904908 }
905909
906- pub fn ident ( & self ) -> Option < Ident > {
907- AttributeExt :: ident ( self )
908- }
909-
910910 pub fn path_matches ( & self , name : & [ Symbol ] ) -> bool {
911911 AttributeExt :: path_matches ( self , name)
912912 }
@@ -938,10 +938,6 @@ impl Attribute {
938938 AttributeExt :: path ( self )
939939 }
940940
941- pub fn ident_path ( & self ) -> Option < SmallVec < [ Ident ; 1 ] > > {
942- AttributeExt :: ident_path ( self )
943- }
944-
945941 pub fn doc_str ( & self ) -> Option < Symbol > {
946942 AttributeExt :: doc_str ( self )
947943 }
0 commit comments