@@ -321,17 +321,18 @@ impl<'s> LintLevelsBuilder<'s> {
321
321
None
322
322
} ;
323
323
let name = meta_item. path . segments . last ( ) . expect ( "empty lint name" ) . ident . name ;
324
- match store. check_lint_name ( & name. as_str ( ) , tool_name) {
324
+ let lint_result = store. check_lint_name ( & name. as_str ( ) , tool_name) ;
325
+ match & lint_result {
325
326
CheckLintNameResult :: Ok ( ids) => {
326
327
let src = LintLevelSource :: Node ( name, li. span ( ) , reason) ;
327
- for & id in ids {
328
+ for & id in * ids {
328
329
self . check_gated_lint ( id, attr. span ) ;
329
330
self . insert_spec ( & mut specs, id, ( level, src) ) ;
330
331
}
331
332
}
332
333
333
334
CheckLintNameResult :: Tool ( result) => {
334
- match result {
335
+ match * result {
335
336
Ok ( ids) => {
336
337
let complete_name = & format ! ( "{}::{}" , tool_name. unwrap( ) , name) ;
337
338
let src = LintLevelSource :: Node (
@@ -343,7 +344,7 @@ impl<'s> LintLevelsBuilder<'s> {
343
344
self . insert_spec ( & mut specs, * id, ( level, src) ) ;
344
345
}
345
346
}
346
- Err ( ( Some ( ids) , new_lint_name) ) => {
347
+ Err ( ( Some ( ids) , ref new_lint_name) ) => {
347
348
let lint = builtin:: RENAMED_AND_REMOVED_LINTS ;
348
349
let ( lvl, src) =
349
350
self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , & sess) ;
@@ -392,21 +393,21 @@ impl<'s> LintLevelsBuilder<'s> {
392
393
393
394
CheckLintNameResult :: Warning ( msg, renamed) => {
394
395
let lint = builtin:: RENAMED_AND_REMOVED_LINTS ;
395
- let ( level , src) =
396
+ let ( renamed_lint_level , src) =
396
397
self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , & sess) ;
397
398
struct_lint_level (
398
399
self . sess ,
399
400
lint,
400
- level ,
401
+ renamed_lint_level ,
401
402
src,
402
403
Some ( li. span ( ) . into ( ) ) ,
403
404
|lint| {
404
405
let mut err = lint. build ( & msg) ;
405
- if let Some ( new_name) = renamed {
406
+ if let Some ( new_name) = & renamed {
406
407
err. span_suggestion (
407
408
li. span ( ) ,
408
409
"use the new name" ,
409
- new_name,
410
+ new_name. to_string ( ) ,
410
411
Applicability :: MachineApplicable ,
411
412
) ;
412
413
}
@@ -444,6 +445,22 @@ impl<'s> LintLevelsBuilder<'s> {
444
445
) ;
445
446
}
446
447
}
448
+ // If this lint was renamed, apply the new lint instead of ignoring the attribute.
449
+ // This happens outside of the match because the new lint should be applied even if
450
+ // we don't warn about the name change.
451
+ if let CheckLintNameResult :: Warning ( _, Some ( new_name) ) = lint_result {
452
+ // Ignore any errors or warnings that happen because the new name is inaccurate
453
+ if let CheckLintNameResult :: Ok ( ids) =
454
+ store. check_lint_name ( & new_name, tool_name)
455
+ {
456
+ let src =
457
+ LintLevelSource :: Node ( Symbol :: intern ( & new_name) , li. span ( ) , reason) ;
458
+ for & id in ids {
459
+ self . check_gated_lint ( id, attr. span ) ;
460
+ self . insert_spec ( & mut specs, id, ( level, src) ) ;
461
+ }
462
+ }
463
+ }
447
464
}
448
465
}
449
466
0 commit comments