diff options
| author | bors <bors@rust-lang.org> | 2023-12-13 04:38:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-13 04:38:30 +0000 |
| commit | 9f1bfe53b60101962501cbfef0456bab5f9bebfc (patch) | |
| tree | bec83af07c2a3aa95c270d7f54029cd3dddddd52 /compiler/rustc_parse/src/parser | |
| parent | 77d16997566dfb2384bcbc504e2579c7ae973666 (diff) | |
| parent | f9078a40ee265222c08a6373aa1a87ba647ee45d (diff) | |
| download | rust-9f1bfe53b60101962501cbfef0456bab5f9bebfc.tar.gz rust-9f1bfe53b60101962501cbfef0456bab5f9bebfc.zip | |
Auto merge of #118900 - workingjubilee:rollup-wkv9hq1, r=workingjubilee
Rollup of 10 pull requests Successful merges: - #118858 (Remove dead codes in core) - #118864 (Fix alignment passed down to LLVM for simd_masked_load) - #118872 (Add rustX check to codeblock attributes lint) - #118873 (fix `waker_getters` tracking issue number) - #118884 (NFC: simplify merging of two vecs) - #118885 (clippy::complexity fixes) - #118886 (Clean up variables in `search.js`) - #118887 (Typo) - #118889 (more clippy::complexity fixes) - #118891 (Actually parse async gen blocks correctly) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 5b0011e9f70..509cef9826b 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1440,21 +1440,23 @@ impl<'a> Parser<'a> { } else if this.eat_keyword(kw::Underscore) { 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. - if this.check_keyword(kw::Async) { + // `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly. + 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(kw::Async) && this.is_gen_block(kw::Gen, 1))) + { + // FIXME: (async) gen closures aren't yet parsed. + this.parse_gen_block() + } else if this.check_keyword(kw::Async) { // FIXME(gen_blocks): Parse `gen async` and suggest swap if this.is_gen_block(kw::Async, 0) { // Check for `async {` and `async move {`, - // or `async gen {` and `async gen move {`. this.parse_gen_block() } else { this.parse_expr_closure() } - } else if this.token.uninterpolated_span().at_least_rust_2024() - && (this.is_gen_block(kw::Gen, 0) - || (this.check_keyword(kw::Async) && this.is_gen_block(kw::Gen, 1))) - { - this.parse_gen_block() } else if this.eat_keyword_noexpect(kw::Await) { this.recover_incorrect_await_syntax(lo, this.prev_token.span) } else { @@ -3227,9 +3229,16 @@ impl<'a> Parser<'a> { if self.eat_keyword(kw::Gen) { GenBlockKind::AsyncGen } else { GenBlockKind::Async } } else { assert!(self.eat_keyword(kw::Gen)); - self.sess.gated_spans.gate(sym::gen_blocks, lo.to(self.token.span)); GenBlockKind::Gen }; + match kind { + GenBlockKind::Async => { + // `async` blocks are stable + } + GenBlockKind::Gen | GenBlockKind::AsyncGen => { + self.sess.gated_spans.gate(sym::gen_blocks, lo.to(self.prev_token.span)); + } + } let capture_clause = self.parse_capture_clause()?; let (attrs, body) = self.parse_inner_attrs_and_block()?; let kind = ExprKind::Gen(capture_clause, body, kind); |
