rust/compiler/rustc_parse/src/parser
bors f967532a47 Auto merge of #118420 - compiler-errors:async-gen, r=eholk
Introduce support for `async gen` blocks

I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`.

**This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078).

### Technical note on the pre-generator-transform yield type:

The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant).

This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden.

r? `@ghost`
2023-12-08 19:13:57 +00:00
..
attr_wrapper.rs Use Session::diagnostic in more places. 2023-12-02 09:01:35 +11:00
attr.rs Use Session::diagnostic in more places. 2023-12-02 09:01:35 +11:00
diagnostics.rs Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errors 2023-12-08 17:08:52 +00:00
expr.rs Auto merge of #118420 - compiler-errors:async-gen, r=eholk 2023-12-08 19:13:57 +00:00
generics.rs Tweak unclosed generics errors 2023-12-01 20:01:39 +00:00
item.rs Support async gen fn 2023-12-08 17:23:26 +00:00
mod.rs Support async gen fn 2023-12-08 17:23:26 +00:00
nonterminal.rs Use Session::diagnostic in more places. 2023-12-02 09:01:35 +11:00
pat.rs Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errors 2023-12-08 17:08:52 +00:00
path.rs More detail when expecting expression but encountering bad macro argument 2023-11-16 16:19:04 +00:00
stmt.rs Rollup merge of #118394 - nnethercote:rm-hir-Ops, r=cjgillot 2023-11-29 04:23:23 +01:00
ty.rs coro_kind -> coroutine_kind 2023-12-08 17:23:25 +00:00