1
- use crate :: errors:: {
2
- CheckNameDeprecated , CheckNameRemoved , CheckNameRenamed , CheckNameUnknown ,
3
- CheckNameUnknownTool , RequestedLevel , UnsupportedGroup ,
1
+ use crate :: errors:: { CheckNameUnknownTool , RequestedLevel , UnsupportedGroup } ;
2
+ use crate :: lints:: {
3
+ DeprecatedLintNameFromCommandLine , RemovedLintFromCommandLine , RenamedLintFromCommandLine ,
4
+ UnknownLintFromCommandLine ,
4
5
} ;
5
6
use crate :: {
6
7
builtin:: MISSING_DOCS ,
@@ -564,33 +565,32 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
564
565
self . sess . emit_err ( UnsupportedGroup { lint_group : crate :: WARNINGS . name_lower ( ) } ) ;
565
566
}
566
567
match self . store . check_lint_name ( lint_name_only, tool_name, self . registered_tools ) {
567
- CheckLintNameResult :: Renamed ( replace) => {
568
- self . sess . emit_warning ( CheckNameRenamed {
569
- lint_name ,
570
- replace : & replace ,
571
- sub : RequestedLevel { level , lint_name } ,
572
- } ) ;
568
+ CheckLintNameResult :: Renamed ( ref replace) => {
569
+ let name = lint_name . as_str ( ) ;
570
+ let suggestion = RenamedLintSuggestion :: WithoutSpan { replace } ;
571
+ let requested_level = RequestedLevel { level , lint_name } ;
572
+ let lint = RenamedLintFromCommandLine { name , suggestion , requested_level } ;
573
+ self . emit_lint ( RENAMED_AND_REMOVED_LINTS , lint ) ;
573
574
}
574
- CheckLintNameResult :: Removed ( reason) => {
575
- self . sess . emit_warning ( CheckNameRemoved {
576
- lint_name,
577
- reason : & reason,
578
- sub : RequestedLevel { level, lint_name } ,
579
- } ) ;
575
+ CheckLintNameResult :: Removed ( ref reason) => {
576
+ let name = lint_name. as_str ( ) ;
577
+ let requested_level = RequestedLevel { level, lint_name } ;
578
+ let lint = RemovedLintFromCommandLine { name, reason, requested_level } ;
579
+ self . emit_lint ( RENAMED_AND_REMOVED_LINTS , lint) ;
580
580
}
581
581
CheckLintNameResult :: NoLint ( suggestion) => {
582
- self . sess . emit_err ( CheckNameUnknown {
583
- lint_name,
584
- suggestion,
585
- sub : RequestedLevel { level, lint_name } ,
586
- } ) ;
582
+ let name = lint_name. clone ( ) ;
583
+ let suggestion =
584
+ suggestion. map ( |replace| UnknownLintSuggestion :: WithoutSpan { replace } ) ;
585
+ let requested_level = RequestedLevel { level, lint_name } ;
586
+ let lint = UnknownLintFromCommandLine { name, suggestion, requested_level } ;
587
+ self . emit_lint ( UNKNOWN_LINTS , lint) ;
587
588
}
588
- CheckLintNameResult :: Tool ( Err ( ( Some ( _) , new_name) ) ) => {
589
- self . sess . emit_warning ( CheckNameDeprecated {
590
- lint_name,
591
- new_name : & new_name,
592
- sub : RequestedLevel { level, lint_name } ,
593
- } ) ;
589
+ CheckLintNameResult :: Tool ( Err ( ( Some ( _) , ref replace) ) ) => {
590
+ let name = lint_name. clone ( ) ;
591
+ let requested_level = RequestedLevel { level, lint_name } ;
592
+ let lint = DeprecatedLintNameFromCommandLine { name, replace, requested_level } ;
593
+ self . emit_lint ( RENAMED_AND_REMOVED_LINTS , lint) ;
594
594
}
595
595
CheckLintNameResult :: NoTool => {
596
596
self . sess . emit_err ( CheckNameUnknownTool {
@@ -963,24 +963,18 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
963
963
964
964
_ if !self . warn_about_weird_lints => { }
965
965
966
- CheckLintNameResult :: Renamed ( new_name ) => {
966
+ CheckLintNameResult :: Renamed ( ref replace ) => {
967
967
let suggestion =
968
- RenamedLintSuggestion { suggestion : sp, replace : new_name . as_str ( ) } ;
968
+ RenamedLintSuggestion :: WithSpan { suggestion : sp, replace } ;
969
969
let name = tool_ident. map ( |tool| format ! ( "{tool}::{name}" ) ) . unwrap_or ( name) ;
970
- self . emit_spanned_lint (
971
- RENAMED_AND_REMOVED_LINTS ,
972
- sp. into ( ) ,
973
- RenamedLint { name : name. as_str ( ) , suggestion } ,
974
- ) ;
970
+ let lint = RenamedLint { name : name. as_str ( ) , suggestion } ;
971
+ self . emit_spanned_lint ( RENAMED_AND_REMOVED_LINTS , sp. into ( ) , lint) ;
975
972
}
976
973
977
- CheckLintNameResult :: Removed ( reason) => {
974
+ CheckLintNameResult :: Removed ( ref reason) => {
978
975
let name = tool_ident. map ( |tool| format ! ( "{tool}::{name}" ) ) . unwrap_or ( name) ;
979
- self . emit_spanned_lint (
980
- RENAMED_AND_REMOVED_LINTS ,
981
- sp. into ( ) ,
982
- RemovedLint { name : name. as_str ( ) , reason : reason. as_str ( ) } ,
983
- ) ;
976
+ let lint = RemovedLint { name : name. as_str ( ) , reason } ;
977
+ self . emit_spanned_lint ( RENAMED_AND_REMOVED_LINTS , sp. into ( ) , lint) ;
984
978
}
985
979
986
980
CheckLintNameResult :: NoLint ( suggestion) => {
@@ -989,13 +983,11 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
989
983
} else {
990
984
name. to_string ( )
991
985
} ;
992
- let suggestion = suggestion
993
- . map ( |replace| UnknownLintSuggestion { suggestion : sp, replace } ) ;
994
- self . emit_spanned_lint (
995
- UNKNOWN_LINTS ,
996
- sp. into ( ) ,
997
- UnknownLint { name, suggestion } ,
998
- ) ;
986
+ let suggestion = suggestion. map ( |replace| {
987
+ UnknownLintSuggestion :: WithSpan { suggestion : sp, replace }
988
+ } ) ;
989
+ let lint = UnknownLint { name, suggestion } ;
990
+ self . emit_spanned_lint ( UNKNOWN_LINTS , sp. into ( ) , lint) ;
999
991
}
1000
992
}
1001
993
// If this lint was renamed, apply the new lint instead of ignoring the attribute.
0 commit comments