rust/compiler/rustc_builtin_macros/src
bors 208dd2032b Auto merge of #118847 - eholk:for-await, r=compiler-errors
Add support for `for await` loops

This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library.

Given a loop like:
```rust
for await i in iter {
    ...
}
```
this is desugared to something like:
```rust
let mut iter = iter.into_async_iter();
while let Some(i) = loop {
    match core::pin::Pin::new(&mut iter).poll_next(cx) {
        Poll::Ready(i) => break i,
        Poll::Pending => yield,
    }
} {
    ...
}
```

This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this.

I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue.

r? `@compiler-errors`
2023-12-22 14:17:10 +00:00
..
assert Desugar for await loops 2023-12-19 12:26:27 -08:00
deriving Give VariantData::Struct named fields, to clairfy recovered. 2023-12-20 00:07:34 +00:00
format_foreign Use as_deref in compiler (but only where it makes sense) 2022-11-16 21:58:58 +00:00
alloc_error_handler.rs Rename Session::span_diagnostic as Session::dcx. 2023-12-18 16:06:21 +11:00
asm.rs Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
assert.rs Don't escape_debug the condition of assert!. 2023-10-10 09:08:11 +11:00
cfg.rs rustc: Move features from Session to GlobalCtxt 2023-08-11 16:51:50 +08:00
cfg_accessible.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
cfg_eval.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
cmdline_attrs.rs Rename ParseSess::span_diagnostic as ParseSess::dcx. 2023-12-18 16:06:21 +11:00
compile_error.rs Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
concat.rs Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
concat_bytes.rs Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstrieb 2023-12-01 13:33:55 +00:00
concat_idents.rs refactor: use by-ref TokenTree iterator to avoid a few clones 2023-05-11 21:59:38 -05:00
derive.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
edition_panic.rs Remove MacDelimiter. 2023-08-03 09:03:30 +10:00
env.rs Implement --env compiler flag 2023-12-10 14:25:57 +01:00
errors.rs Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
format.rs unwrap return Option value, as it always returns Some for some fns 2023-11-28 14:52:21 +03:00
format_foreign.rs unwrap return Option value, as it always returns Some for some fns 2023-11-28 14:52:21 +03:00
global_allocator.rs Rename Session::span_diagnostic as Session::dcx. 2023-12-18 16:06:21 +11:00
lib.rs Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
proc_macro_harness.rs Rename many DiagCtxt arguments. 2023-12-18 16:06:22 +11:00
source_util.rs remove redundant imports 2023-12-10 10:56:22 +08:00
standard_library_imports.rs rustc: Move features from Session to GlobalCtxt 2023-08-11 16:51:50 +08:00
test.rs Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
test_harness.rs Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
trace_macros.rs Migrate some rustc_builtin_macros to SessionDiagnostic 2023-06-25 01:32:30 +08:00
type_ascribe.rs Add unstable type_ascribe macro 2022-11-19 22:16:42 +01:00
util.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00