about summary refs log tree commit diff
path: root/tests/ui/async-await
diff options
context:
space:
mode:
authorAndrew Zhogin <andrew.zhogin@gmail.com>2025-06-17 10:14:05 +0700
committerAndrew Zhogin <andrew.zhogin@gmail.com>2025-06-18 09:04:34 +0700
commiteee2d7b1016d6f2743c5f61989b28e05fefd9aff (patch)
tree8742856f63ccff0392c1fcf2de804b724ac95e39 /tests/ui/async-await
parent55d436467c351b56253deeba209ae2553d1c243f (diff)
downloadrust-eee2d7b1016d6f2743c5f61989b28e05fefd9aff.tar.gz
rust-eee2d7b1016d6f2743c5f61989b28e05fefd9aff.zip
AsyncDrop trait without sync Drop generates an error
Diffstat (limited to 'tests/ui/async-await')
-rw-r--r--tests/ui/async-await/async-drop/async-without-sync.rs19
-rw-r--r--tests/ui/async-await/async-drop/async-without-sync.stderr10
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/async-await/async-drop/async-without-sync.rs b/tests/ui/async-await/async-drop/async-without-sync.rs
new file mode 100644
index 00000000000..8a748636cc7
--- /dev/null
+++ b/tests/ui/async-await/async-drop/async-without-sync.rs
@@ -0,0 +1,19 @@
+//@ edition: 2024
+#![feature(async_drop)]
+#![allow(incomplete_features)]
+#![crate_type = "lib"]
+
+use std::future::AsyncDrop;
+use std::pin::Pin;
+
+async fn foo() {
+    let _st = St;
+}
+
+struct St;
+
+impl AsyncDrop for St { //~ ERROR: `AsyncDrop` impl without `Drop` impl
+    async fn drop(self: Pin<&mut Self>) {
+        println!("123");
+    }
+}
diff --git a/tests/ui/async-await/async-drop/async-without-sync.stderr b/tests/ui/async-await/async-drop/async-without-sync.stderr
new file mode 100644
index 00000000000..0eaca322dc0
--- /dev/null
+++ b/tests/ui/async-await/async-drop/async-without-sync.stderr
@@ -0,0 +1,10 @@
+error: `AsyncDrop` impl without `Drop` impl
+  --> $DIR/async-without-sync.rs:15:1
+   |
+LL | impl AsyncDrop for St {
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds
+
+error: aborting due to 1 previous error
+