rust/compiler/rustc_ast_passes/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
..
ast_validation.rs Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, r=compiler-errors 2023-12-22 02:00:55 +00:00
errors.rs Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, r=compiler-errors 2023-12-22 02:00:55 +00:00
feature_gate.rs Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
lib.rs Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00
node_count.rs Remove unused span argument from walk_fn. 2022-09-12 13:24:27 +10:00
show_span.rs Rename ShowSpanVisitor::span_diagnostic as ShowSpanVisitor::dcx. 2023-12-18 16:06:21 +11:00