rust/library/core/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
..
alloc Indicate that multiplication in Layout::array cannot overflow 2023-11-23 22:05:45 -05:00
array remove redundant imports 2023-12-10 10:56:22 +08:00
ascii fix Debug impl for AsciiChar 2023-09-01 12:29:40 +01:00
async_iter Desugar for await loops 2023-12-19 12:26:27 -08:00
cell Add some optimizations 2023-10-13 14:54:33 +02:00
char remove redundant imports 2023-12-10 10:56:22 +08:00
cmp Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
convert remove redundant imports 2023-12-10 10:56:22 +08:00
ffi Update c_str.rs 2023-12-14 19:05:03 -05:00
fmt Remove dead codes in core 2023-12-12 07:03:37 +00:00
future remove redundant imports 2023-12-10 10:56:22 +08:00
hash Add insta-stable std:#️⃣:{DefaultHasher, RandomState} exports 2023-11-02 20:35:20 -04:00
intrinsics Disable new intrinsics for bootstrap 2023-12-18 21:41:50 -05:00
io Move BorrowedBuf and BorrowedCursor from std:io to core::io 2023-11-09 07:10:11 +09:00
iter remove redundant imports 2023-12-10 10:56:22 +08:00
macros Add diagnostic items for a few of core's builtin macros 2023-11-04 17:00:51 -07:00
mem remove redundant imports 2023-12-10 10:56:22 +08:00
net Add link to is_benchmark from the Ipv6Addr::is_global documentation 2023-12-15 20:53:54 +01:00
num Rollup merge of #118397 - Zalathar:nonzero, r=WaffleLapkin 2023-11-28 09:28:39 +01:00
ops remove redundant imports 2023-12-10 10:56:22 +08:00
panic Increase the reach of panic_immediate_abort 2023-10-29 09:31:07 -04:00
prelude Revert "Remove #[alloc_error_handler] from the compiler and library" 2023-04-25 00:08:35 +02:00
ptr Stabilize ptr::{from_ref, from_mut} 2023-12-15 08:34:59 -08:00
slice Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-Simulacrum 2023-12-15 21:32:57 -08:00
str Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-Simulacrum 2023-12-15 21:32:57 -08:00
sync Substitute version placeholders 2023-11-15 19:40:51 -05:00
task fix waker_getters tracking issue number 2023-12-12 14:38:13 +01:00
unicode Apply changes to fix python linting errors 2023-06-16 20:56:01 -04:00
any.rs Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay 2023-12-15 20:19:53 +01:00
arch.rs use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
ascii.rs ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs core is now compilable 2023-04-16 07:20:26 +00:00
borrow.rs doc: replace wrong punctuation mark 2023-07-28 14:46:17 +02:00
cell.rs Use OnceCell in cell module documentation 2023-11-29 17:42:44 +01:00
clone.rs remove redundant imports 2023-12-10 10:56:22 +08:00
cmp.rs Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco 2023-12-11 14:33:16 +00:00
default.rs Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
error.md Fix minor grammar typo 2023-09-06 09:47:22 -07:00
error.rs Documentation cleanup for core::error::Request. 2023-11-06 11:38:27 +01:00
escape.rs Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
hint.rs Address review feedback 2023-11-25 23:58:51 +00:00
internal_macros.rs add track_caller for arith ops 2023-11-24 00:54:06 +08:00
intrinsics.rs Add core::intrinsics::simd 2023-12-17 21:16:59 -05:00
lib.rs Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, r=workingjubilee 2023-12-02 18:04:01 +00:00
marker.rs Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco 2023-11-08 20:42:32 +00:00
option.rs Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkov 2023-11-18 12:45:42 +00:00
panic.rs Address review feedback 2023-11-25 23:58:51 +00:00
panicking.rs use the usual attributes for panic_misaligned_pointer_dereference 2023-11-27 11:10:32 +01:00
pin.rs remove redundant imports 2023-12-10 10:56:22 +08:00
primitive.rs
primitive_docs.rs do not allow ABI mismatches inside repr(C) types 2023-12-17 09:34:25 +01:00
result.rs Stabilize result_option_inspect 2023-10-18 07:35:23 +08:00
time.rs Add Duration::abs_diff 2023-11-05 19:45:17 +01:00
tuple.rs Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkov 2023-12-13 06:37:08 +00:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00