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
373
373
.suggestion = use `..=` for an inclusive range
374
374
375
375
lint-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;
8
8
use rustc_lint_defs:: { Applicability , LintExpectationId } ;
9
9
use rustc_span:: edition:: LATEST_STABLE_EDITION ;
10
10
use rustc_span:: symbol:: { Ident , Symbol } ;
11
- use rustc_span:: { Span , DUMMY_SP } ;
11
+ use rustc_span:: { edition :: Edition , Span , DUMMY_SP } ;
12
12
use std:: borrow:: Cow ;
13
13
use std:: fmt;
14
14
use std:: hash:: { Hash , Hasher } ;
@@ -115,6 +115,12 @@ impl IntoDiagnosticArg for String {
115
115
}
116
116
}
117
117
118
+ impl IntoDiagnosticArg for Edition {
119
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
120
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
121
+ }
122
+ }
123
+
118
124
impl IntoDiagnosticArg for Symbol {
119
125
fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
120
126
self . to_ident_string ( ) . into_diagnostic_arg ( )
Original file line number Diff line number Diff line change @@ -2033,10 +2033,12 @@ impl KeywordIdents {
2033
2033
}
2034
2034
2035
2035
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)
2037
2039
. span_suggestion (
2038
2040
ident. span ,
2039
- "you can use a raw identifier to stay compatible" ,
2041
+ fluent :: lint :: suggestion ,
2040
2042
format ! ( "r#{}" , ident) ,
2041
2043
Applicability :: MachineApplicable ,
2042
2044
)
You can’t perform that action at this time.
0 commit comments