@@ -321,17 +321,18 @@ impl<'s> LintLevelsBuilder<'s> {
321321 None
322322 } ;
323323 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 {
325326 CheckLintNameResult :: Ok ( ids) => {
326327 let src = LintLevelSource :: Node ( name, li. span ( ) , reason) ;
327- for & id in ids {
328+ for & id in * ids {
328329 self . check_gated_lint ( id, attr. span ) ;
329330 self . insert_spec ( & mut specs, id, ( level, src) ) ;
330331 }
331332 }
332333
333334 CheckLintNameResult :: Tool ( result) => {
334- match result {
335+ match * result {
335336 Ok ( ids) => {
336337 let complete_name = & format ! ( "{}::{}" , tool_name. unwrap( ) , name) ;
337338 let src = LintLevelSource :: Node (
@@ -343,7 +344,7 @@ impl<'s> LintLevelsBuilder<'s> {
343344 self . insert_spec ( & mut specs, * id, ( level, src) ) ;
344345 }
345346 }
346- Err ( ( Some ( ids) , new_lint_name) ) => {
347+ Err ( ( Some ( ids) , ref new_lint_name) ) => {
347348 let lint = builtin:: RENAMED_AND_REMOVED_LINTS ;
348349 let ( lvl, src) =
349350 self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , & sess) ;
@@ -392,21 +393,21 @@ impl<'s> LintLevelsBuilder<'s> {
392393
393394 CheckLintNameResult :: Warning ( msg, renamed) => {
394395 let lint = builtin:: RENAMED_AND_REMOVED_LINTS ;
395- let ( level , src) =
396+ let ( renamed_lint_level , src) =
396397 self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , & sess) ;
397398 struct_lint_level (
398399 self . sess ,
399400 lint,
400- level ,
401+ renamed_lint_level ,
401402 src,
402403 Some ( li. span ( ) . into ( ) ) ,
403404 |lint| {
404405 let mut err = lint. build ( & msg) ;
405- if let Some ( new_name) = renamed {
406+ if let Some ( new_name) = & renamed {
406407 err. span_suggestion (
407408 li. span ( ) ,
408409 "use the new name" ,
409- new_name,
410+ new_name. to_string ( ) ,
410411 Applicability :: MachineApplicable ,
411412 ) ;
412413 }
@@ -444,6 +445,22 @@ impl<'s> LintLevelsBuilder<'s> {
444445 ) ;
445446 }
446447 }
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+ }
447464 }
448465 }
449466
0 commit comments