Open
Description
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)