Skip to content

E0277 nolonger points at phantom .await #114584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1717,12 +1717,7 @@ impl<'a> Parser<'a> {
self.recover_await_prefix(await_sp)?
};
let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
let kind = match expr.kind {
// Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
// or `foo()?.await` (the very reason we went with postfix syntax 😅).
ExprKind::Try(_) => ExprKind::Err,
_ => ExprKind::Await(expr, await_sp),
};
let kind = ExprKind::Err;
let expr = self.mk_expr(lo.to(sp), kind);
self.maybe_recover_from_bad_qpath(expr)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/parser/issues/issue-113203.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Checks what happens when we attempt to use the await keyword as a prefix. Span
// incorrectly emitted an `.await` in E0277 which does not exist
// edition:2018
fn main() {
await {}()
//~^ ERROR incorrect use of `await`
}
8 changes: 8 additions & 0 deletions tests/ui/parser/issues/issue-113203.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: incorrect use of `await`
--> $DIR/issue-113203.rs:5:5
|
LL | await {}()
| ^^^^^^^^ help: `await` is a postfix operation: `{}.await`

error: aborting due to previous error