File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -373,3 +373,6 @@ lint-builtin-ellipsis-inclusive-range-patterns = `...` range patterns are deprec
373373 .suggestion = use `..=` for an inclusive range
374374
375375lint-builtin-unnameable-test-items = cannot test inner items
376+
377+ lint-builtin-keyword-idents = `{ $kw } ` is a keyword in the { $next } edition
378+ .suggestion = you can use a raw identifier to stay compatible
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use rustc_error_messages::FluentValue;
88use rustc_lint_defs:: { Applicability , LintExpectationId } ;
99use rustc_span:: edition:: LATEST_STABLE_EDITION ;
1010use rustc_span:: symbol:: { Ident , Symbol } ;
11- use rustc_span:: { Span , DUMMY_SP } ;
11+ use rustc_span:: { edition :: Edition , Span , DUMMY_SP } ;
1212use std:: borrow:: Cow ;
1313use std:: fmt;
1414use std:: hash:: { Hash , Hasher } ;
@@ -115,6 +115,12 @@ impl IntoDiagnosticArg for String {
115115 }
116116}
117117
118+ impl IntoDiagnosticArg for Edition {
119+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
120+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
121+ }
122+ }
123+
118124impl IntoDiagnosticArg for Symbol {
119125 fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
120126 self . to_ident_string ( ) . into_diagnostic_arg ( )
Original file line number Diff line number Diff line change @@ -2033,10 +2033,12 @@ impl KeywordIdents {
20332033 }
20342034
20352035 cx. struct_span_lint ( KEYWORD_IDENTS , ident. span , |lint| {
2036- lint. build ( & format ! ( "`{}` is a keyword in the {} edition" , ident, next_edition) )
2036+ lint. build ( fluent:: lint:: builtin_keyword_idents)
2037+ . set_arg ( "kw" , ident. clone ( ) )
2038+ . set_arg ( "next" , next_edition)
20372039 . span_suggestion (
20382040 ident. span ,
2039- "you can use a raw identifier to stay compatible" ,
2041+ fluent :: lint :: suggestion ,
20402042 format ! ( "r#{}" , ident) ,
20412043 Applicability :: MachineApplicable ,
20422044 )
You can’t perform that action at this time.
0 commit comments