AsyncDrop broken normal Drop
Open
Nobody has claimed this yet.
C-bug
F-async_drop
needs-triage
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(async_drop)]
use std::future::{pending, ready};
use std::time::Duration;
use compio::runtime;
use compio::runtime::Runtime;
use futures_util::{select, StreamExt};
use futures_util::FutureExt;
use futures_util::stream::FuturesUnordered;
fn main() {
Runtime::new().unwrap().block_on(async {
select! {
_ = run().fuse() => (),
_ = compio::time::sleep(Duration::from_millis(100)).fuse() => (),
}
})
}
async fn run() {
runtime::spawn(async {
let _st = St(1);
let tasks = runtime::spawn(async {
let _st = St(2);
pending::<()>().await
});
let futs = FuturesUnordered::new();
futs.push(tasks);
futs.for_each(|_| ready(())).await;
})
.await
.unwrap()
}
struct St(usize);
impl Drop for St {
fn drop(&mut self) {
println!("drop st {}", self.0);
}
}
I expected to see this happen:
print normal logs,
drop st 1
drop st 2
Instead, this happened:
drop st 2
Meta
rustc --version --verbose:
rustc 1.97.0-nightly (c935696dd 2026-04-29)
binary: rustc
commit-hash: c935696dd07ca51e6fba2f6579919eea2a50863b
commit-date: 2026-04-29
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4
it remove the async drop feature, print correctly
drop st 1
drop st 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied main, run, and St::drop reproduction, running it with and without #![feature(async_drop)] on the noted nightly compiler. Trace why the outer St(1) is not dropped when async drop is enabled, and verify the fix by restoring both expected log lines while preserving the existing St(2) behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100