Skip to content

AsyncDrop broken normal Drop #156008

@Sherlock-Holo

Description

@Sherlock-Holo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-async_drop`#![feature(async_drop)]`needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions