Skip to content

Commit 93a427e

Browse files
committed
migrate recover_from_await_method_call diagnostic
1 parent 29ed9a5 commit 93a427e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

compiler/rustc_error_messages/locales/en-US/parser.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)