rust/compiler
bors 4a2fe4491e Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk
Rework support for async closures; allow them to return futures that borrow from the closure's captures

This PR implements a new lowering for async closures via `TyKind::CoroutineClosure` which handles the curious relationship between the closure and the coroutine that it returns.

I wrote up a bunch in [this hackmd](https://hackmd.io/`@compiler-errors/S1HvqQxca)` which will be copied to the dev guide after this PR lands, and hopefully left sufficient comments in the source code explaining why this change is as large as it is.

This also necessitates that they begin implementing the `AsyncFn`-family of traits, rather than the `Fn`-family of traits -- if you need `Fn` implementations, you should probably use the non-sugar `|| async {}` syntax instead.

Notably this PR does not yet implement `async Fn()` syntax sugar for bounds, but I expect to add those soon (**edit:** #120392). For now, users must use `AsyncFn()` traits directly, which necessitates adding the `async_fn_traits` feature gate as well. I will add this as a follow-up very soon.

r? oli-obk

This is based on top of #120322, but that PR is minimal.
2024-02-06 15:04:01 +00:00
..
rustc
rustc_abi Fix rustc_abi build on stable 2024-01-16 21:15:31 +01:00
rustc_arena Fix Stable trait and its impls to work with the new with_tables 2024-01-19 09:42:51 +00:00
rustc_ast Add async bound modifier to enable async Fn bounds 2024-01-31 16:59:19 +00:00
rustc_ast_lowering Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk 2024-02-06 15:04:01 +00:00
rustc_ast_passes Correctly check never_type feature gating 2024-02-01 20:01:04 +01:00
rustc_ast_pretty Add async bound modifier to enable async Fn bounds 2024-01-31 16:59:19 +00:00
rustc_attr Stop using String for error codes. 2024-01-29 07:41:41 +11:00
rustc_baked_icu_data
rustc_borrowck More comments, final tweaks 2024-02-06 02:22:58 +00:00
rustc_builtin_macros Rollup merge of #120342 - oli-obk:track_errors6, r=nnethercote 2024-01-30 16:57:49 +01:00
rustc_codegen_cranelift Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrum 2024-02-05 15:41:40 +00:00
rustc_codegen_gcc Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_codegen_llvm Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_codegen_ssa Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_const_eval Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_data_structures Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errors 2024-02-05 06:37:14 +01:00
rustc_driver
rustc_driver_impl Stop using String for error codes. 2024-01-29 07:41:41 +11:00
rustc_error_codes Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errors 2024-02-05 06:37:14 +01:00
rustc_error_messages Remove unused features 2024-01-25 14:01:33 +00:00
rustc_errors Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errors 2024-02-05 06:37:14 +01:00
rustc_expand Add async bound modifier to enable async Fn bounds 2024-01-31 16:59:19 +00:00
rustc_feature #![feature(inline_const_pat)] is no longer incomplete 2024-02-01 10:27:54 +00:00
rustc_fluent_macro annotate-snippets: update to 0.10 2024-01-07 16:53:32 +03:00
rustc_fs_util
rustc_graphviz
rustc_hir Teach typeck/borrowck/solvers how to deal with async closures 2024-02-06 02:22:58 +00:00
rustc_hir_analysis More comments, final tweaks 2024-02-06 02:22:58 +00:00
rustc_hir_pretty hir: Use InferArg in ArrayLen::Infer 2024-01-28 02:04:39 +03:00
rustc_hir_typeck More comments, final tweaks 2024-02-06 02:22:58 +00:00
rustc_incremental hir: Simplify hir_owner_nodes query 2024-01-30 15:00:52 +03:00
rustc_index Auto merge of #120024 - Mark-Simulacrum:fast-union-merge, r=cjgillot 2024-01-27 22:26:37 +00:00
rustc_index_macros Restrict access to the private field of newtype indexes 2024-01-19 15:38:47 +00:00
rustc_infer Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_interface SilentEmitter::fatal_note doesn't need to be optional. 2024-02-03 09:02:50 +11:00
rustc_lexer Use unescape_unicode for raw C string literals. 2024-01-25 12:28:11 +11:00
rustc_lint Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_lint_defs remove illegal_floating_point_literal_pattern lint 2024-01-26 17:25:02 +01:00
rustc_llvm review 2024-02-06 12:44:40 +03:00
rustc_log
rustc_macros Rollup merge of #120475 - Nilstrieb:cargo-build-my-a-, r=michaelwoerister 2024-01-30 16:57:50 +01:00
rustc_metadata Remove the lifetime from DiagnosticArgValue. 2024-01-30 18:46:06 +11:00
rustc_middle Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_mir_build Teach typeck/borrowck/solvers how to deal with async closures 2024-02-06 02:22:58 +00:00
rustc_mir_dataflow More comments, final tweaks 2024-02-06 02:22:58 +00:00
rustc_mir_transform Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_monomorphize Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_next_trait_solver Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_parse Auto merge of #120392 - compiler-errors:async-bound-modifier, r=davidtwco,fmease 2024-02-06 00:45:11 +00:00
rustc_parse_format Rename the unescaping functions. 2024-01-25 12:28:11 +11:00
rustc_passes Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_pattern_analysis Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_privacy Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
rustc_query_impl Remove unused features 2024-01-25 14:01:33 +00:00
rustc_query_system Stop using String for error codes. 2024-01-29 07:41:41 +11:00
rustc_resolve Rollup merge of #120592 - trevyn:cleanup-to-string, r=Nilstrieb 2024-02-03 21:29:43 +01:00
rustc_serialize Remove unused features 2024-01-25 14:01:33 +00:00
rustc_session Simplify future breakage control flow. 2024-02-03 09:02:50 +11:00
rustc_smir Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_span Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk 2024-02-06 15:04:01 +00:00
rustc_symbol_mangling Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
rustc_target Rollup merge of #120661 - xen0n:loong-medium-cmodel, r=heiher,Nilstrieb 2024-02-05 11:07:28 +01:00
rustc_trait_selection More comments, final tweaks 2024-02-06 02:22:58 +00:00
rustc_traits Remove unused features 2024-01-25 14:01:33 +00:00
rustc_transmute Remove unused features 2024-01-25 14:01:33 +00:00
rustc_ty_utils Fudge coroutine argument for CoroutineKindShim in fn_sig_for_fn_abi 2024-02-06 02:53:06 +00:00
rustc_type_ir Bless tests, add comments 2024-02-06 02:22:58 +00:00
stable_mir Remove the abi_amdgpu_kernel feature 2024-01-30 15:46:40 +00:00