rust/compiler/rustc_hir/src
bors aca749eefc Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obk
Add simple async drop glue generation

This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work).

This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit).

Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html).

This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work.

Feature completeness:

 - [x] `AsyncDrop` trait
 - [ ] `async_drop_in_place_raw`/async drop glue generation support for
   - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.)
   - [x] Arrays and slices (array pointer is unsized into slice pointer)
   - [x] ADTs (enums, structs, unions)
   - [x] tuple-like types (tuples, closures)
   - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait))
   - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948)
 - [x] Async drop glue includes sync drop glue code
 - [x] Cleanup branch generation for `async_drop_in_place_raw`
 - [ ] Union rejects non-trivially async destructible fields
 - [ ] `AsyncDrop` implementation requires same bounds as type definition
 - [ ] Skip trivially destructible fields (optimization)
 - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators
 - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop)
 - [ ] Automatic async drop at the end of the scope in async context
2024-04-23 02:10:23 +00:00
..
arena.rs Remove unused arena kinds in rustc_hir and rustc_middle. 2023-11-20 15:05:26 +11:00
def_path_hash_map.rs Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
def.rs Opaque types have no namespace 2024-04-15 21:27:30 -04:00
definitions.rs Try explicitly outlining the panic machinery 2024-04-04 09:46:53 +00:00
diagnostic_items.rs Replace some instances of FxHashMap/FxHashSet with stable alternatives (mostly in rustc_hir and rustc_ast_lowering) 2023-12-18 21:03:32 +01:00
hir_id.rs rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
hir.rs Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstrieb 2024-04-18 09:47:45 +00:00
intravisit.rs Add hir::Node::PreciseCapturingNonLifetimeArg 2024-04-15 16:45:25 -04:00
lang_items.rs Add simple async drop glue generation 2024-04-16 20:45:07 +03:00
lib.rs step cfgs 2024-03-20 08:49:13 -04:00
pat_util.rs Rename BindingAnnotation to BindingMode 2024-04-17 09:34:39 -04:00
stable_hash_impls.rs Simplify BodyId hashing. 2024-01-16 23:52:30 +00:00
target.rs Change DefKind::Static to a struct variant 2024-03-12 05:53:46 +00:00
tests.rs Construct SourceMap at the same time as SessionGlobals. 2024-04-16 13:02:53 +10:00
weak_lang_items.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00