File tree 2 files changed +17
-8
lines changed
rustc_error_messages/locales/en-US
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -28,3 +28,7 @@ parser-incorrect-use-of-await =
28
28
incorrect use of `await`
29
29
.parentheses-suggestion = `await` is not a method call, remove the parentheses
30
30
.postfix-suggestion = `await` is a postfix operation
31
+
32
+ parser-in-in-typo =
33
+ expected iterable, found keyword `in`
34
+ .suggestion = remove the duplicated `in`
Original file line number Diff line number Diff line change @@ -325,6 +325,15 @@ struct IncorrectAwait {
325
325
question_mark : & ' static str ,
326
326
}
327
327
328
+ #[ derive( SessionDiagnostic ) ]
329
+ #[ error( slug = "parser-in-in-typo" ) ]
330
+ struct InInTypo {
331
+ #[ primary_span]
332
+ span : Span ,
333
+ #[ suggestion( applicability = "machine-applicable" ) ]
334
+ sugg_span : Span ,
335
+ }
336
+
328
337
// SnapshotParser is used to create a snapshot of the parser
329
338
// without causing duplicate errors being emitted when the `Parser`
330
339
// is dropped.
@@ -1953,14 +1962,10 @@ impl<'a> Parser<'a> {
1953
1962
pub ( super ) fn check_for_for_in_in_typo ( & mut self , in_span : Span ) {
1954
1963
if self . eat_keyword ( kw:: In ) {
1955
1964
// a common typo: `for _ in in bar {}`
1956
- self . struct_span_err ( self . prev_token . span , "expected iterable, found keyword `in`" )
1957
- . span_suggestion_short (
1958
- in_span. until ( self . prev_token . span ) ,
1959
- "remove the duplicated `in`" ,
1960
- String :: new ( ) ,
1961
- Applicability :: MachineApplicable ,
1962
- )
1963
- . emit ( ) ;
1965
+ self . sess . emit_err ( InInTypo {
1966
+ span : self . prev_token . span ,
1967
+ sugg_span : in_span. until ( self . prev_token . span ) ,
1968
+ } ) ;
1964
1969
}
1965
1970
}
1966
1971
You can’t perform that action at this time.
0 commit comments