Skip to content

Make parser aware of await where macro calls are expected #60829

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,8 @@ impl<'a> Parser<'a> {
db.span_label(self.span, "expected expression");
db.note("variable declaration using `let` is a statement");
return Err(db);
} else if self.span.rust_2018() && self.eat_keyword(keywords::Await) {
} else if self.span.rust_2018() && self.eat_keyword(keywords::Await)
&& self.check(&token::Not) {
// FIXME: remove this branch when `await!` is no longer supported
// https://github.com/rust-lang/rust/issues/60610
self.expect(&token::Not)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ macro_rules! await {
}

fn main() {
match await { await => () } //~ ERROR expected `!`, found `{`
match await { await => () } //~ ERROR expected expression, found `{`
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ help: you can escape reserved keywords to use them as identifiers
LL | macro_rules! r#await {
| ^^^^^^^

error: expected `!`, found `{`
error: expected expression, found `{`
--> $DIR/2018-edition-error-in-non-macro-position.rs:26:17
|
LL | match await { await => () }
| ----- ^ expected `!`
| ----- ^ expected expression
| |
| while parsing this match expression

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/await-keyword/2018-edition-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ use self::outer_mod::await::await; //~ ERROR expected identifier
//~^ ERROR expected identifier, found reserved keyword `await`

fn main() {
match await { await => () } //~ ERROR expected `!`, found `{`
match await { await => () } //~ ERROR expected expression, found `{`
}
4 changes: 2 additions & 2 deletions src/test/ui/await-keyword/2018-edition-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ help: you can escape reserved keywords to use them as identifiers
LL | use self::outer_mod::await::r#await;
| ^^^^^^^

error: expected `!`, found `{`
error: expected expression, found `{`
--> $DIR/2018-edition-error.rs:13:17
|
LL | match await { await => () }
| ----- ^ expected `!`
| ----- ^ expected expression
| |
| while parsing this match expression

Expand Down