@@ -210,27 +210,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
210
210
if let Some ( items) = & attr. meta_item_list ( ) {
211
211
if let Some ( ident) = attr. ident_str ( ) {
212
212
match ident {
213
- "allow" | "warn" | "deny" | "forbid" => {
214
- check_clippy_lint_names ( cx, items) ;
215
- } ,
216
- _ => { } ,
217
- }
213
+ "allow" | "warn" | "deny" | "forbid" => {
214
+ check_clippy_lint_names ( cx, items) ;
215
+ } ,
216
+ _ => { } ,
217
+ }
218
218
if items. is_empty ( ) || !attr. check_name ( "deprecated" ) {
219
- return ;
220
- }
221
- for item in items {
222
- if_chain ! {
219
+ return ;
220
+ }
221
+ for item in items {
222
+ if_chain ! {
223
223
if let NestedMetaItem :: MetaItem ( mi) = & item;
224
- if let MetaItemKind :: NameValue ( lit) = & mi. node;
224
+ if let MetaItemKind :: NameValue ( lit) = & mi. node;
225
225
if mi. check_name( "since" ) ;
226
- then {
226
+ then {
227
227
check_semver( cx, item. span( ) , lit) ;
228
+ }
228
229
}
229
230
}
230
231
}
231
232
}
232
233
}
233
- }
234
234
235
235
fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx Item ) {
236
236
if is_relevant_item ( cx. tcx , item) {
@@ -244,54 +244,54 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
244
244
if let Some ( lint_list) = & attr. meta_item_list ( ) {
245
245
if let Some ( ident) = attr. ident_str ( ) {
246
246
match ident {
247
- "allow" | "warn" | "deny" | "forbid" => {
248
- // whitelist `unused_imports` and `deprecated` for `use` items
249
- // and `unused_imports` for `extern crate` items with `macro_use`
250
- for lint in lint_list {
251
- match item. node {
252
- ItemKind :: Use ( ..) => {
253
- if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
254
- return ;
255
- }
256
- } ,
257
- ItemKind :: ExternCrate ( ..) => {
258
- if is_word ( lint, "unused_imports" ) && skip_unused_imports {
259
- return ;
260
- }
261
- if is_word ( lint, "unused_extern_crates" ) {
262
- return ;
263
- }
264
- } ,
265
- _ => { } ,
266
- }
267
- }
268
- let line_span = last_line_of_span ( cx, attr. span ) ;
269
-
270
- if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
271
- if sugg. contains ( "#[" ) {
272
- span_lint_and_then (
273
- cx,
274
- USELESS_ATTRIBUTE ,
275
- line_span,
276
- "useless lint attribute" ,
277
- |db| {
278
- sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
279
- db. span_suggestion (
280
- line_span,
281
- "if you just forgot a `!`, use" ,
282
- sugg,
283
- Applicability :: MachineApplicable ,
284
- ) ;
247
+ "allow" | "warn" | "deny" | "forbid" => {
248
+ // whitelist `unused_imports` and `deprecated` for `use` items
249
+ // and `unused_imports` for `extern crate` items with `macro_use`
250
+ for lint in lint_list {
251
+ match item. node {
252
+ ItemKind :: Use ( ..) => {
253
+ if is_word ( lint, "unused_imports" ) || is_word ( lint, "deprecated" ) {
254
+ return ;
255
+ }
285
256
} ,
286
- ) ;
257
+ ItemKind :: ExternCrate ( ..) => {
258
+ if is_word ( lint, "unused_imports" ) && skip_unused_imports {
259
+ return ;
260
+ }
261
+ if is_word ( lint, "unused_extern_crates" ) {
262
+ return ;
263
+ }
264
+ } ,
265
+ _ => { } ,
266
+ }
287
267
}
288
- }
289
- } ,
290
- _ => { } ,
268
+ let line_span = last_line_of_span ( cx, attr. span ) ;
269
+
270
+ if let Some ( mut sugg) = snippet_opt ( cx, line_span) {
271
+ if sugg. contains ( "#[" ) {
272
+ span_lint_and_then (
273
+ cx,
274
+ USELESS_ATTRIBUTE ,
275
+ line_span,
276
+ "useless lint attribute" ,
277
+ |db| {
278
+ sugg = sugg. replacen ( "#[" , "#![" , 1 ) ;
279
+ db. span_suggestion (
280
+ line_span,
281
+ "if you just forgot a `!`, use" ,
282
+ sugg,
283
+ Applicability :: MachineApplicable ,
284
+ ) ;
285
+ } ,
286
+ ) ;
287
+ }
288
+ }
289
+ } ,
290
+ _ => { } ,
291
+ }
291
292
}
292
293
}
293
294
}
294
- }
295
295
} ,
296
296
_ => { } ,
297
297
}
@@ -527,7 +527,7 @@ impl EarlyLintPass for CfgAttrPass {
527
527
if feature_item. check_name( "rustfmt" ) ;
528
528
// check for `rustfmt_skip` and `rustfmt::skip`
529
529
if let Some ( skip_item) = & items[ 1 ] . meta_item( ) ;
530
- if skip_item. check_name( "rustfmt_skip" ) ||
530
+ if skip_item. check_name( "rustfmt_skip" ) ||
531
531
skip_item. path. segments. last( ) . expect( "empty path in attribute" ) . ident. name == "skip" ;
532
532
// Only lint outer attributes, because custom inner attributes are unstable
533
533
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
0 commit comments