rust/compiler/rustc_resolve/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
..
diagnostics Implement the unused_macro_rules lint 2022-05-05 19:13:00 +02:00
late Dont suggest ! for path in function call if it has generic args 2023-11-27 01:02:37 +00:00
build_reduced_graph.rs merge DefKind::Coroutine into DefKind::Closure 2023-11-26 21:05:08 +08:00
check_unused.rs Rollup merge of #116905 - Fenex:refactor/compiler/resolve, r=petrochenkov 2023-10-26 17:45:43 +02:00
def_collector.rs Make some matches exhaustive to avoid bugs, fix tools 2023-12-08 17:23:26 +00:00
diagnostics.rs tip for define macro name after macro_rules! 2023-12-06 23:19:39 +08:00
effective_visibilities.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
errors.rs tip for define macro name after macro_rules! 2023-12-06 23:19:39 +08:00
ident.rs Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug. 2023-12-02 09:01:19 +11:00
imports.rs Use the glob binding in resolve_rustdoc_path process 2023-12-06 21:48:19 +08:00
late.rs Auto merge of #118420 - compiler-errors:async-gen, r=eholk 2023-12-08 19:13:57 +00:00
lib.rs rustc: Harmonize DefKind and DefPathData 2023-12-03 16:24:56 +03:00
macros.rs Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug. 2023-12-02 09:01:19 +11:00
rustdoc.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00