@@ -80,20 +80,6 @@ impl Attribute {
8080}
8181
8282impl AttributeExt for Attribute {
83- /// For a single-segment attribute, returns its name; otherwise, returns `None`.
84- fn name ( & self ) -> Option < Symbol > {
85- use SyntheticAttr :: * ;
86- match & self . kind {
87- AttrKind :: Normal ( normal) => normal. item . name ( ) ,
88- AttrKind :: Synthetic ( CfgTrace ( _) | CfgAttrTrace ( _) ) => None ,
89- AttrKind :: DocComment ( ..) => None ,
90- AttrKind :: Generated ( generated) => match generated. path ( ) {
91- [ name] => Some ( * name) ,
92- _ => None ,
93- } ,
94- }
95- }
96-
9783 fn path_matches ( & self , name : & [ Symbol ] ) -> bool {
9884 match & self . kind {
9985 AttrKind :: Normal ( normal) => {
@@ -837,10 +823,6 @@ impl MetaItemLit {
837823}
838824
839825pub trait AttributeExt : Debug + ' static {
840- /// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
841- /// return the name of the attribute; otherwise, returns `None`.
842- fn name ( & self ) -> Option < Symbol > ;
843-
844826 /// Gets the value literal, as string, when using `#[attr = value]`
845827 fn value_str ( & self ) -> Option < Symbol > ;
846828
@@ -866,13 +848,7 @@ pub trait AttributeExt: Debug + 'static {
866848 fn doc_resolution_scope ( & self ) -> Option < AttrStyle > ;
867849}
868850
869- // FIXME(fn_delegation): use function delegation instead of manually forwarding
870-
871851impl Attribute {
872- pub fn name ( & self ) -> Option < Symbol > {
873- AttributeExt :: name ( self )
874- }
875-
876852 pub fn value_str ( & self ) -> Option < Symbol > {
877853 AttributeExt :: value_str ( self )
878854 }
@@ -904,6 +880,20 @@ impl Attribute {
904880 }
905881 }
906882
883+ /// For a single-segment attribute, returns its name; otherwise, returns `None`.
884+ pub fn name ( & self ) -> Option < Symbol > {
885+ use SyntheticAttr :: * ;
886+ match & self . kind {
887+ AttrKind :: Normal ( normal) => normal. item . name ( ) ,
888+ AttrKind :: Synthetic ( CfgTrace ( _) | CfgAttrTrace ( _) ) => None ,
889+ AttrKind :: DocComment ( ..) => None ,
890+ AttrKind :: Generated ( generated) => match generated. path ( ) {
891+ [ name] => Some ( * name) ,
892+ _ => None ,
893+ } ,
894+ }
895+ }
896+
907897 /// Returns true if the attribute's first *and only* path segment is equal to the passed-in
908898 /// symbol.
909899 #[ inline]
0 commit comments