rust/compiler/rustc_hir/src
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
..
arena.rs Remove unused arena kinds in rustc_hir and rustc_middle. 2023-11-20 15:05:26 +11:00
def_path_hash_map.rs
def.rs rustc: Harmonize DefKind and DefPathData 2023-12-03 16:24:56 +03:00
definitions.rs rustc: Harmonize DefKind and DefPathData 2023-12-03 16:24:56 +03:00
diagnostic_items.rs
hir_id.rs Replace no_ord_impl with orderable. 2023-11-22 18:38:17 +11:00
hir.rs Auto merge of #118420 - compiler-errors:async-gen, r=eholk 2023-12-08 19:13:57 +00:00
intravisit.rs Remove #[rustc_host], use internal desugaring 2023-12-05 01:15:21 +00:00
lang_items.rs Implement async gen blocks 2023-12-08 17:23:25 +00:00
lib.rs Remove unused feature. 2023-11-20 16:20:45 +11:00
pat_util.rs
stable_hash_impls.rs
target.rs Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
tests.rs Replace two create_default_session_if_not_set_then uses. 2023-11-02 19:35:04 +11:00
weak_lang_items.rs