Repository navigation
Open
Labels
A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-async_drop`#![feature(async_drop)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamWG-asyncWorking group: Async & await
Description
This is a tracking issue for the async drop codegen from MCP "727" (rust-lang/compiler-team#727).
The feature gate for the issue is #![feature(async_drop))].
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
- Implement the async drop codegen
-
AsyncDroptrait (Add simple async drop glue generation #121801) -
async_drop_in_place_raw/async drop glue generation support for- Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.), arrays and slices (array pointer is unsized into slice pointer), ADTs (enums, structs, unions), tuple-like types (tuples, closures) (Add simple async drop glue generation #121801)
- Dynamic types (
dyn Trait) - Coroutines (Async drop codegen #123948)
- Type level support (possibly outside of the scope of this tracking issue)
- Union rejects non-trivially async destructible fields
-
AsyncDropimplementation requires same bounds as type definition - Synchronously undroppable types
- Optimizations
- Skip trivially destructible fields (optimization) (Implement
needs_async_dropin rustc and optimize async drop glue #124662) - New
TyKind::AdtAsyncDestructorand get rid of combinators (obsoleted by Async drop codegen #123948)
- Skip trivially destructible fields (optimization) (Implement
- Automatic async drop at the end of the scope in async context (Async drop codegen #123948)
-
- Adjust documentation (see instructions on rustc-dev-guide)
-
Formatting for new syntax has been added to the Style Guide (nightly-style-procedure) - Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Async drop for dynamic types (
dyn Trait)- One proposed design: https://zetanumbers.github.io/book/async-drop-design.html#dyn_trait
- Drop of async destructors
-
AsyncDropandDropshould somehow be combined to not duplicate implementations (possibly outside of the scope of this tracking issue)
Implementation history
- Add simple async drop glue generation #121801
- Implement
needs_async_dropin rustc and optimize async drop glue #124662 - Async drop codegen #123948
- Many fixes after Async drop codegen #123948 - https://github.com/rust-lang/rust/issues?q=label%3AF-async_drop%20is%3Apr
- Expand async drops during drop elaboration #156649
Reacted by orzogc, Iizuki, Kirill Ivanov, Eden, LeoniePhiline, Cherry, thexia, iTrooz, Guillermo Lloret Talavera, Nathanael Demacon and 41 more
Reacted by José Luis Cruz, oxalica, Trevin Miller, Mustafa Gezen, LeoniePhiline, Max Wase, bart, Diego Reis, Cathal, Junzhuo ZHOU and 12 more
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-async_drop`#![feature(async_drop)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamWG-asyncWorking group: Async & await
Activity
zetanumbers commentedon Jun 14, 2024
@rustbot label +T-compiler +T-lang +WG-async +A-async-await +F-async-drop
Rollup merge of rust-lang#126596 - zetanumbers:async-drop-tracking-is…
Rollup merge of rust-lang#126596 - zetanumbers:async-drop-tracking-is…
Unrolled build for rust-lang#126596
Rollup merge of rust-lang#126594 - zetanumbers:fix-cross-crate-async-…
Rollup merge of rust-lang#126594 - zetanumbers:fix-cross-crate-async-…
Rollup merge of rust-lang#126594 - zetanumbers:fix-cross-crate-async-…
Rollup merge of rust-lang#126594 - zetanumbers:fix-cross-crate-async-…
Unrolled build for rust-lang#126594
Merge 'bindings/rust: Initial support for transactions API' from Dieg…
AndyGauge commentedon Jul 14, 2026
I'm not sure what is left to do on Union rejects trivially async destructible fields since AsyncDrop requires Drop and Drop throws E0740.
P8L1 commentedon Jul 14, 2026
@AndyGauge I think the main work still left is the dyn case. I'm unsure about unions at the moment. But I know for a fact dyn has not been handled. I have reached out to @nikomatsakis for advice on a PR to lay the groundwork for dyn earlier this week. (It is an edited version of Zetanumbers's approuch). I am yet to receive a reply. My Zulip is P_L1 catch me there if you want more info about what I want to do!
Have a good one!
Merge 'bindings/rust: Initial support for transactions API' from Dieg…