mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-21 12:07:31 +00:00
Rollup merge of #142362 - Veykril:push-rzmrsswqourz, r=oli-obk
Add expectation for `{` when parsing lone coroutine qualifiers Fixes https://github.com/rust-lang/rust/issues/80931
This commit is contained in:
commit
e78b619cad
@ -1520,22 +1520,20 @@ impl<'a> Parser<'a> {
|
|||||||
Ok(this.mk_expr(this.prev_token.span, ExprKind::Underscore))
|
Ok(this.mk_expr(this.prev_token.span, ExprKind::Underscore))
|
||||||
} else if this.token_uninterpolated_span().at_least_rust_2018() {
|
} else if this.token_uninterpolated_span().at_least_rust_2018() {
|
||||||
// `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
|
// `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
|
||||||
|
let at_async = this.check_keyword(exp!(Async));
|
||||||
|
// check for `gen {}` and `gen move {}`
|
||||||
|
// or `async gen {}` and `async gen move {}`
|
||||||
|
// FIXME: (async) gen closures aren't yet parsed.
|
||||||
|
// FIXME(gen_blocks): Parse `gen async` and suggest swap
|
||||||
if this.token_uninterpolated_span().at_least_rust_2024()
|
if this.token_uninterpolated_span().at_least_rust_2024()
|
||||||
// check for `gen {}` and `gen move {}`
|
&& this.is_gen_block(kw::Gen, at_async as usize)
|
||||||
// or `async gen {}` and `async gen move {}`
|
|
||||||
&& (this.is_gen_block(kw::Gen, 0)
|
|
||||||
|| (this.check_keyword(exp!(Async)) && this.is_gen_block(kw::Gen, 1)))
|
|
||||||
{
|
{
|
||||||
// FIXME: (async) gen closures aren't yet parsed.
|
|
||||||
this.parse_gen_block()
|
this.parse_gen_block()
|
||||||
} else if this.check_keyword(exp!(Async)) {
|
// Check for `async {` and `async move {`,
|
||||||
// FIXME(gen_blocks): Parse `gen async` and suggest swap
|
} else if this.is_gen_block(kw::Async, 0) {
|
||||||
if this.is_gen_block(kw::Async, 0) {
|
this.parse_gen_block()
|
||||||
// Check for `async {` and `async move {`,
|
} else if at_async {
|
||||||
this.parse_gen_block()
|
this.parse_expr_closure()
|
||||||
} else {
|
|
||||||
this.parse_expr_closure()
|
|
||||||
}
|
|
||||||
} else if this.eat_keyword_noexpect(kw::Await) {
|
} else if this.eat_keyword_noexpect(kw::Await) {
|
||||||
this.recover_incorrect_await_syntax(lo)
|
this.recover_incorrect_await_syntax(lo)
|
||||||
} else {
|
} else {
|
||||||
@ -2407,6 +2405,14 @@ impl<'a> Parser<'a> {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let ClosureBinder::NotPresent = binder
|
||||||
|
&& coroutine_kind.is_some()
|
||||||
|
{
|
||||||
|
// coroutine closures and generators can have the same qualifiers, so we might end up
|
||||||
|
// in here if there is a missing `|` but also no `{`. Adjust the expectations in that case.
|
||||||
|
self.expected_token_types.insert(TokenType::OpenBrace);
|
||||||
|
}
|
||||||
|
|
||||||
let capture_clause = self.parse_capture_clause()?;
|
let capture_clause = self.parse_capture_clause()?;
|
||||||
let (fn_decl, fn_arg_span) = self.parse_fn_block_decl()?;
|
let (fn_decl, fn_arg_span) = self.parse_fn_block_decl()?;
|
||||||
let decl_hi = self.prev_token.span;
|
let decl_hi = self.prev_token.span;
|
||||||
|
@ -44,22 +44,22 @@ note: while trying to match `r#async`
|
|||||||
LL | (r#async) => (1)
|
LL | (r#async) => (1)
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/auxiliary/edition-kw-macro-2015.rs:27:23
|
--> $DIR/auxiliary/edition-kw-macro-2015.rs:27:23
|
||||||
|
|
|
|
||||||
LL | ($i: ident) => ($i)
|
LL | ($i: ident) => ($i)
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
|
|
||||||
::: $DIR/edition-keywords-2018-2015-parsing.rs:22:8
|
::: $DIR/edition-keywords-2018-2015-parsing.rs:22:8
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
|
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
|
||||||
| -------------------- in this macro invocation
|
| -------------------- in this macro invocation
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:24:24
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:24:24
|
||||||
|
|
|
|
||||||
LL | if passes_tt!(async) == 1 {}
|
LL | if passes_tt!(async) == 1 {}
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:29:33
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:29:33
|
||||||
|
@ -44,34 +44,34 @@ note: while trying to match `r#async`
|
|||||||
LL | (r#async) => (1)
|
LL | (r#async) => (1)
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/auxiliary/edition-kw-macro-2018.rs:27:23
|
--> $DIR/auxiliary/edition-kw-macro-2018.rs:27:23
|
||||||
|
|
|
|
||||||
LL | ($i: ident) => ($i)
|
LL | ($i: ident) => ($i)
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
|
|
||||||
::: $DIR/edition-keywords-2018-2018-parsing.rs:29:8
|
::: $DIR/edition-keywords-2018-2018-parsing.rs:29:8
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
|
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
|
||||||
| -------------------- in this macro invocation
|
| -------------------- in this macro invocation
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:31:24
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:31:24
|
||||||
|
|
|
|
||||||
LL | if passes_tt!(async) == 1 {}
|
LL | if passes_tt!(async) == 1 {}
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:14:23
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:14:23
|
||||||
|
|
|
|
||||||
LL | ($i: ident) => ($i)
|
LL | ($i: ident) => ($i)
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
||||||
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
|
error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:35:30
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:35:30
|
||||||
|
|
|
|
||||||
LL | if local_passes_tt!(async) == 1 {}
|
LL | if local_passes_tt!(async) == 1 {}
|
||||||
| ^ expected one of `move`, `use`, `|`, or `||`
|
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:40:33
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:40:33
|
||||||
|
@ -27,10 +27,10 @@ fn in_try() {
|
|||||||
let x = 0;
|
let x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(#80931)
|
|
||||||
fn in_async() {
|
fn in_async() {
|
||||||
async
|
async
|
||||||
let x = 0; //~ ERROR expected one of `move`, `use`, `|`, or `||`, found keyword `let`
|
let x = 0;
|
||||||
|
//~^ ERROR expected one of `move`, `use`, `{`, `|`, or `||`, found keyword `let`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(#78168)
|
// FIXME(#78168)
|
||||||
|
@ -43,11 +43,11 @@ error: expected expression, found reserved keyword `try`
|
|||||||
LL | try
|
LL | try
|
||||||
| ^^^ expected expression
|
| ^^^ expected expression
|
||||||
|
|
||||||
error: expected one of `move`, `use`, `|`, or `||`, found keyword `let`
|
error: expected one of `move`, `use`, `{`, `|`, or `||`, found keyword `let`
|
||||||
--> $DIR/block-no-opening-brace.rs:33:9
|
--> $DIR/block-no-opening-brace.rs:32:9
|
||||||
|
|
|
|
||||||
LL | async
|
LL | async
|
||||||
| - expected one of `move`, `use`, `|`, or `||`
|
| - expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
LL | let x = 0;
|
LL | let x = 0;
|
||||||
| ^^^ unexpected token
|
| ^^^ unexpected token
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error: expected one of `move`, `use`, `|`, or `||`, found `Move`
|
error: expected one of `move`, `use`, `{`, `|`, or `||`, found `Move`
|
||||||
--> $DIR/async-move.rs:4:11
|
--> $DIR/async-move.rs:4:11
|
||||||
|
|
|
|
||||||
LL | async Move {}
|
LL | async Move {}
|
||||||
| ^^^^ expected one of `move`, `use`, `|`, or `||`
|
| ^^^^ expected one of `move`, `use`, `{`, `|`, or `||`
|
||||||
|
|
|
|
||||||
help: write keyword `move` in lowercase
|
help: write keyword `move` in lowercase
|
||||||
|
|
|
|
||||||
|
Loading…
Reference in New Issue
Block a user