@@ -125,14 +125,14 @@ impl LintPass for AttrPass {
125
125
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AttrPass {
126
126
fn check_attribute ( & mut self , cx : & LateContext < ' a , ' tcx > , attr : & ' tcx Attribute ) {
127
127
if let Some ( ref items) = attr. meta_item_list ( ) {
128
- if items. is_empty ( ) || attr. name ( ) . map_or ( true , |n| n != "deprecated" ) {
128
+ if items. is_empty ( ) || attr. name ( ) != "deprecated" {
129
129
return ;
130
130
}
131
131
for item in items {
132
132
if_chain ! {
133
133
if let NestedMetaItemKind :: MetaItem ( ref mi) = item. node;
134
134
if let MetaItemKind :: NameValue ( ref lit) = mi. node;
135
- if mi. ident . name == "since" ;
135
+ if mi. name( ) == "since" ;
136
136
then {
137
137
check_semver( cx, item. span, lit) ;
138
138
}
@@ -149,40 +149,38 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
149
149
ItemExternCrate ( _) | ItemUse ( _, _) => {
150
150
for attr in & item. attrs {
151
151
if let Some ( ref lint_list) = attr. meta_item_list ( ) {
152
- if let Some ( name) = attr. name ( ) {
153
- match & * name. as_str ( ) {
154
- "allow" | "warn" | "deny" | "forbid" => {
155
- // whitelist `unused_imports` and `deprecated`
156
- for lint in lint_list {
157
- if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
158
- if let ItemUse ( _, _) = item. node {
159
- return ;
160
- }
152
+ match & * attr. name ( ) . as_str ( ) {
153
+ "allow" | "warn" | "deny" | "forbid" => {
154
+ // whitelist `unused_imports` and `deprecated`
155
+ for lint in lint_list {
156
+ if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
157
+ if let ItemUse ( _, _) = item. node {
158
+ return ;
161
159
}
162
160
}
163
- let line_span = last_line_of_span ( cx, attr. span ) ;
161
+ }
162
+ let line_span = last_line_of_span ( cx, attr. span ) ;
164
163
165
- if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
166
- if sugg. contains ( "#[" ) {
167
- span_lint_and_then (
168
- cx,
169
- USELESS_ATTRIBUTE ,
170
- line_span,
171
- "useless lint attribute" ,
172
- |db| {
173
- sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
174
- db. span_suggestion (
175
- line_span,
176
- "if you just forgot a `!`, use" ,
177
- sugg,
178
- ) ;
179
- } ,
180
- ) ;
181
- }
164
+ if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
165
+ if sugg. contains ( "#[" ) {
166
+ span_lint_and_then (
167
+ cx,
168
+ USELESS_ATTRIBUTE ,
169
+ line_span,
170
+ "useless lint attribute" ,
171
+ |db| {
172
+ sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
173
+ db. span_suggestion (
174
+ line_span,
175
+ "if you just forgot a `!`, use" ,
176
+ sugg,
177
+ ) ;
178
+ } ,
179
+ ) ;
182
180
}
183
- } ,
184
- _ => { } ,
185
- }
181
+ }
182
+ } ,
183
+ _ => { } ,
186
184
}
187
185
}
188
186
}
@@ -294,7 +292,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
294
292
}
295
293
296
294
if let Some ( ref values) = attr. meta_item_list ( ) {
297
- if values. len ( ) != 1 || attr. name ( ) . map_or ( true , |n| n != "inline" ) {
295
+ if values. len ( ) != 1 || attr. name ( ) != "inline" {
298
296
continue ;
299
297
}
300
298
if is_word ( & values[ 0 ] , "always" ) {
@@ -328,7 +326,7 @@ fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
328
326
329
327
fn is_word ( nmi : & NestedMetaItem , expected : & str ) -> bool {
330
328
if let NestedMetaItemKind :: MetaItem ( ref mi) = nmi. node {
331
- mi. is_word ( ) && mi. ident . name == expected
329
+ mi. is_word ( ) && mi. name ( ) == expected
332
330
} else {
333
331
false
334
332
}
0 commit comments