diff options
| author | bors <bors@rust-lang.org> | 2023-12-22 14:17:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-22 14:17:10 +0000 |
| commit | 4ad06d1adf1d4afe1ded4c09ad2bb3dc782680d7 (patch) | |
| tree | 7d3fe1a5744eb5c16e4d6f650a0ceeaf809ea4b5 /tests/debuginfo/enum-thinlto.rs | |
| parent | 062845421b8a678f2807f0682db429025dd18ebe (diff) | |
| parent | 212ea0359c52f63cf05cdd73cf5c30f42aae2aa8 (diff) | |
| download | rust-4ad06d1adf1d4afe1ded4c09ad2bb3dc782680d7.tar.gz rust-4ad06d1adf1d4afe1ded4c09ad2bb3dc782680d7.zip | |
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`
Diffstat (limited to 'tests/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions
