Open
Description
I tried this code:
lib.rs
#![feature(async_drop)]
use std::future::AsyncDrop;
use std::pin::Pin;
use std::time::Duration;
use tokio::time;
pub async fn run() {
let _st = St(Duration::from_secs(1));
}
pub struct St(Duration);
impl Drop for St {
fn drop(&mut self) {}
}
impl AsyncDrop for St {
async fn drop(self: Pin<&mut Self>) {
time::sleep(self.0).await;
println!("async drop");
}
}
main.rs
#[tokio::main]
async fn main() {
ttt::run().await;
}
Cargo.toml
[package]
name = "ttt"
version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1.45.1", features = ["rt", "macros", "time", "rt-multi-thread"] }
I expected to see this happen: exit with 0
Instead, this happened:
[1] 4076757 segmentation fault (core dumped) ./target/debug/ttt
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (586ad391f 2025-06-15)
binary: rustc
commit-hash: 586ad391f5ee4519acc7cae340e34673bae762b1
commit-date: 2025-06-15
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitCategory: This is a bug.`#![feature(async_drop)]`Issue: Correct Rust code lowers to incorrect machine codeIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.