Skip to content

async drop not work without sync drop #140696

Open
@Sherlock-Holo

Description

@Sherlock-Holo

I tried this code:

#![feature(async_drop)]

use std::future::AsyncDrop;
use std::pin::Pin;

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let _st = St;
}

struct St;

impl AsyncDrop for St {
    async fn drop(self: Pin<&mut Self>) {
        println!("123");
    }
}

I expected to see this happen:

should print 123

Instead, this happened:

nothing

if try this codes

#![feature(async_drop)]

use std::future::AsyncDrop;
use std::pin::Pin;

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let _st = St;
}

struct St;

impl Drop for St {
    fn drop(&mut self) {
        println!("456")
    }
}

impl AsyncDrop for St {
    async fn drop(self: Pin<&mut Self>) {
        println!("123");
    }
}

it print 123

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (2e6882ac5 2025-05-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-async_drop`#![feature(async_drop)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions