@@ -91,10 +91,10 @@ impl<'a> StripUnconfigured<'a> {
91
91
/// is in the original source file. Gives a compiler error if the syntax of
92
92
/// the attribute is incorrect.
93
93
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 {
95
95
return vec ! [ attr] ;
96
96
}
97
- if attr. tokens . len ( ) == 0 {
97
+ if attr. tokens . is_empty ( ) {
98
98
self . sess . span_diagnostic
99
99
. struct_span_err (
100
100
attr. span ,
@@ -108,7 +108,7 @@ impl<'a> StripUnconfigured<'a> {
108
108
<https://doc.rust-lang.org/reference/conditional-compilation.html\
109
109
#the-cfg_attr-attribute>")
110
110
. emit ( ) ;
111
- return Vec :: new ( ) ;
111
+ return vec ! [ ] ;
112
112
}
113
113
114
114
let ( cfg_predicate, expanded_attrs) = match attr. parse ( self . sess , |parser| {
@@ -133,17 +133,18 @@ impl<'a> StripUnconfigured<'a> {
133
133
Ok ( result) => result,
134
134
Err ( mut e) => {
135
135
e. emit ( ) ;
136
- return Vec :: new ( ) ;
136
+ return vec ! [ ] ;
137
137
}
138
138
} ;
139
139
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] ;
145
143
}
146
144
145
+ // At this point we know the attribute is considered used.
146
+ attr:: mark_used ( & attr) ;
147
+
147
148
if attr:: cfg_matches ( & cfg_predicate, self . sess , self . features ) {
148
149
// We call `process_cfg_attr` recursively in case there's a
149
150
// `cfg_attr` inside of another `cfg_attr`. E.g.
@@ -159,7 +160,7 @@ impl<'a> StripUnconfigured<'a> {
159
160
} ) )
160
161
. collect ( )
161
162
} else {
162
- Vec :: new ( )
163
+ vec ! [ ]
163
164
}
164
165
}
165
166
0 commit comments