This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,7 @@ parser-incorrect-semicolon =
2323 expected item, found `;`
2424 .suggestion = remove this semicolon
2525 .help = { $name } declarations are not followed by a semicolon
26+
27+ parser-incorrect-use-of-await =
28+ incorrect use of `await`
29+ .suggestion = `await` is not a method call, remove the parentheses
Original file line number Diff line number Diff line change @@ -306,6 +306,14 @@ struct IncorrectSemicolon<'a> {
306306 name : & ' a str ,
307307}
308308
309+ #[ derive( SessionDiagnostic ) ]
310+ #[ error( slug = "parser-incorrect-use-of-await" ) ]
311+ struct IncorrectUseOfAwait {
312+ #[ primary_span]
313+ #[ suggestion( applicability = "machine-applicable" ) ]
314+ span : Span ,
315+ }
316+
309317// SnapshotParser is used to create a snapshot of the parser
310318// without causing duplicate errors being emitted when the `Parser`
311319// is dropped.
@@ -1659,14 +1667,8 @@ impl<'a> Parser<'a> {
16591667 self . bump ( ) ; // (
16601668 let sp = lo. to ( self . token . span ) ;
16611669 self . bump ( ) ; // )
1662- self . struct_span_err ( sp, "incorrect use of `await`" )
1663- . span_suggestion (
1664- sp,
1665- "`await` is not a method call, remove the parentheses" ,
1666- String :: new ( ) ,
1667- Applicability :: MachineApplicable ,
1668- )
1669- . emit ( ) ;
1670+
1671+ self . sess . emit_err ( IncorrectUseOfAwait { span : sp } ) ;
16701672 }
16711673 }
16721674
You can’t perform that action at this time.
0 commit comments