diff options
| author | bors <bors@rust-lang.org> | 2025-06-11 22:01:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-11 22:01:33 +0000 |
| commit | 31d0d2123d36de10c2611b842299cce5f447ddf7 (patch) | |
| tree | 3ef95b1ce6ab65c16108803ae33c4dc975adfc6e /compiler/rustc_parse/src/parser/expr.rs | |
| parent | e703dff8fe220b78195c53478e83fb2f68d8499c (diff) | |
| parent | c97dca69897a656895141ca708a4ed64c26fb304 (diff) | |
| download | rust-31d0d2123d36de10c2611b842299cce5f447ddf7.tar.gz rust-31d0d2123d36de10c2611b842299cce5f447ddf7.zip | |
Auto merge of #142381 - matthiaskrgr:rollup-si4xbko, r=matthiaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#142305 (Remove unneeded `check_id` calls as they are already called in `visit_id` in `EarlyContextAndPass` type)
- rust-lang/rust#142314 (remove ice group pings from `triagebot.toml`)
- rust-lang/rust#142343 (remove myself from the project)
- rust-lang/rust#142346 (Add tracing import to execution context)
- rust-lang/rust#142356 (Fix enter_trace_span!() using wrong $crate paths)
- rust-lang/rust#142362 (Add expectation for `{` when parsing lone coroutine qualifiers)
- rust-lang/rust#142364 (Do not warn on `rust.incremental` when using download CI rustc)
- rust-lang/rust#142369 (Improve some attribute docs and rename groups)
- rust-lang/rust#142374 (Fix missing newline trim in bootstrap)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index a298c4d4dec..93489aa8ee9 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1520,22 +1520,20 @@ impl<'a> Parser<'a> { Ok(this.mk_expr(this.prev_token.span, ExprKind::Underscore)) } else if this.token_uninterpolated_span().at_least_rust_2018() { // `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() - // check for `gen {}` and `gen move {}` - // 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))) + && this.is_gen_block(kw::Gen, at_async as usize) { - // FIXME: (async) gen closures aren't yet parsed. this.parse_gen_block() - } else if this.check_keyword(exp!(Async)) { - // FIXME(gen_blocks): Parse `gen async` and suggest swap - if this.is_gen_block(kw::Async, 0) { - // Check for `async {` and `async move {`, - this.parse_gen_block() - } else { - this.parse_expr_closure() - } + // Check for `async {` and `async move {`, + } else if this.is_gen_block(kw::Async, 0) { + this.parse_gen_block() + } else if at_async { + this.parse_expr_closure() } else if this.eat_keyword_noexpect(kw::Await) { this.recover_incorrect_await_syntax(lo) } else { @@ -2407,6 +2405,14 @@ impl<'a> Parser<'a> { 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 (fn_decl, fn_arg_span) = self.parse_fn_block_decl()?; let decl_hi = self.prev_token.span; |
