rust/compiler
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
..
rustc
rustc_abi Annotate panic! reasons during enum layout 2023-12-15 02:21:31 -08:00
rustc_arena rustc_arena: add alloc_str 2023-12-05 17:52:51 -08:00
rustc_ast Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_ast_lowering Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_ast_passes Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_ast_pretty Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_attr Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Remove unnecessary param-env from lexical region resolution and fully structural relations 2023-12-19 15:10:26 +00:00
rustc_builtin_macros Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_codegen_cranelift Merge commit '3a9bf729322fb5035518f99b9d76a742bf7c124e' into sync_cg_clif-2023-12-19 2023-12-19 12:46:39 +00:00
rustc_codegen_gcc Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_codegen_llvm Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_codegen_ssa Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_const_eval Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_data_structures NFC don't convert types to identical types 2023-12-15 23:56:24 +01:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
rustc_error_codes E0761: module directory has .rs suffix 2023-12-20 17:05:56 +01:00
rustc_error_messages Remove rustc_error_messages/messages.ftl. 2023-11-26 08:37:27 +11:00
rustc_errors Remove unused DiagCtxt::span_bug_no_panic. 2023-12-19 20:58:49 +11:00
rustc_expand Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, r=compiler-errors 2023-12-22 02:00:55 +00:00
rustc_feature Desugar for await loops 2023-12-19 12:26:27 -08:00
rustc_fluent_macro Add a useful comment. 2023-11-26 08:38:02 +11:00
rustc_fs_util
rustc_graphviz remove unused pub fn 2023-11-23 14:11:02 +03:00
rustc_hir Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_hir_analysis Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_hir_pretty Give VariantData::Struct named fields, to clairfy recovered. 2023-12-20 00:07:34 +00:00
rustc_hir_typeck Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_incremental Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
rustc_index Make rustc_index::bit_set available on stable 2023-12-15 16:58:38 +01:00
rustc_index_macros Put backticks around some attributes in doc comments. 2023-11-27 09:37:01 +11:00
rustc_infer Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_interface Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
rustc_lexer Rename some unescaping functions. 2023-12-13 14:17:50 +11:00
rustc_lint Plumb awaitness of for loops 2023-12-19 12:26:20 -08:00
rustc_lint_defs Remove the lint outright 2023-12-16 01:28:06 +00:00
rustc_llvm Rollup merge of #118941 - krasimirgg:llvm-cov, r=nikic 2023-12-18 17:03:11 +01:00
rustc_log rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
rustc_macros Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_metadata Auto merge of #119173 - compiler-errors:direct-coro-kind, r=TaKO8Ki 2023-12-22 04:07:40 +00:00
rustc_middle Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_mir_build Auto merge of #116821 - Nadrieril:fix-opaque-ice, r=compiler-errors 2023-12-22 12:12:12 +00:00
rustc_mir_dataflow NFC don't convert types to identical types 2023-12-15 23:56:24 +01:00
rustc_mir_transform Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_monomorphize Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_next_trait_solver Opportunistically resolve region var in canonicalizer 2023-12-15 05:02:37 +00:00
rustc_parse Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_parse_format Auto merge of #117819 - fmease:rustc_parse_format-stable-rustc, r=Nilstrieb 2023-11-15 14:55:35 +00:00
rustc_passes Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_pattern_analysis Reveal opaque types in exhaustiveness checking 2023-12-20 14:43:00 +01:00
rustc_privacy resolve: Eagerly feed closure visibilities 2023-12-20 13:42:58 +03:00
rustc_query_impl QueryContext: rename try_collect_active_jobs -> collect_active_jobs and change it's return type from Option<QueryMap> to QueryMap 2023-11-27 18:13:15 +03:00
rustc_query_system Use .into_diagnostic() less. 2023-12-18 20:46:13 +11:00
rustc_resolve Auto merge of #118847 - eholk:for-await, r=compiler-errors 2023-12-22 14:17:10 +00:00
rustc_serialize Call FileEncoder::finish in rmeta encoding 2023-11-22 22:49:22 -05:00
rustc_session Add EmitResult associated type to EmissionGuarantee. 2023-12-19 09:52:02 +11:00
rustc_smir Rollup merge of #119141 - celinval:smir-instance-args, r=compiler-errors 2023-12-20 21:18:59 +01:00
rustc_span Desugar for await loops 2023-12-19 12:26:27 -08:00
rustc_symbol_mangling Add level arg to into_diagnostic. 2023-12-19 09:19:25 +11:00
rustc_target Fix name error in aarch64_apple_watchos tier 3 target 2023-12-21 13:53:11 +08:00
rustc_trait_selection Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors 2023-12-22 00:03:57 +00:00
rustc_traits add unused NormalizesTo predicate 2023-12-07 17:52:51 +01:00
rustc_transmute Update itertools to 0.11. 2023-11-22 08:13:21 +11:00
rustc_ty_utils Rollup merge of #118871 - tmiasko:coroutine-maybe-uninit-fields, r=compiler-errors 2023-12-13 18:03:33 +01:00
rustc_type_ir Auto merge of #118970 - aliemjay:rollup-or33al2, r=aliemjay 2023-12-15 08:51:00 +00:00
stable_mir Rollup merge of #119141 - celinval:smir-instance-args, r=compiler-errors 2023-12-20 21:18:59 +01:00