@@ -91,10 +91,10 @@ impl<'a> StripUnconfigured<'a> {
9191 /// is in the original source file. Gives a compiler error if the syntax of
9292 /// the attribute is incorrect.
9393 fn process_cfg_attr ( & mut self , attr : ast:: Attribute ) -> Vec < ast:: Attribute > {
94- if ! attr. check_name ( sym:: cfg_attr) {
94+ if attr. path != sym:: cfg_attr {
9595 return vec ! [ attr] ;
9696 }
97- if attr. tokens . len ( ) == 0 {
97+ if attr. tokens . is_empty ( ) {
9898 self . sess . span_diagnostic
9999 . struct_span_err (
100100 attr. span ,
@@ -108,7 +108,7 @@ impl<'a> StripUnconfigured<'a> {
108108 <https://doc.rust-lang.org/reference/conditional-compilation.html\
109109 #the-cfg_attr-attribute>")
110110 . emit ( ) ;
111- return Vec :: new ( ) ;
111+ return vec ! [ ] ;
112112 }
113113
114114 let ( cfg_predicate, expanded_attrs) = match attr. parse ( self . sess , |parser| {
@@ -133,17 +133,18 @@ impl<'a> StripUnconfigured<'a> {
133133 Ok ( result) => result,
134134 Err ( mut e) => {
135135 e. emit ( ) ;
136- return Vec :: new ( ) ;
136+ return vec ! [ ] ;
137137 }
138138 } ;
139139
140- // Check feature gate and lint on zero attributes in source. Even if the feature is gated,
141- // we still compute as if it wasn't, since the emitted error will stop compilation further
142- // along the compilation.
143- if expanded_attrs. len ( ) == 0 {
144- // FIXME: Emit unused attribute lint here.
140+ // Lint on zero attributes in source.
141+ if expanded_attrs. is_empty ( ) {
142+ return vec ! [ attr] ;
145143 }
146144
145+ // At this point we know the attribute is considered used.
146+ attr:: mark_used ( & attr) ;
147+
147148 if attr:: cfg_matches ( & cfg_predicate, self . sess , self . features ) {
148149 // We call `process_cfg_attr` recursively in case there's a
149150 // `cfg_attr` inside of another `cfg_attr`. E.g.
@@ -159,7 +160,7 @@ impl<'a> StripUnconfigured<'a> {
159160 } ) )
160161 . collect ( )
161162 } else {
162- Vec :: new ( )
163+ vec ! [ ]
163164 }
164165 }
165166
0 commit comments