about summary refs log tree commit diff
path: root/tests/ui/async-await/async-drop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/async-await/async-drop')
-rw-r--r--tests/ui/async-await/async-drop/type-parameter.rs16
-rw-r--r--tests/ui/async-await/async-drop/type-parameter.stderr11
-rw-r--r--tests/ui/async-await/async-drop/unexpected-sort.rs18
-rw-r--r--tests/ui/async-await/async-drop/unexpected-sort.stderr32
4 files changed, 77 insertions, 0 deletions
diff --git a/tests/ui/async-await/async-drop/type-parameter.rs b/tests/ui/async-await/async-drop/type-parameter.rs
new file mode 100644
index 00000000000..dde5f9f8e64
--- /dev/null
+++ b/tests/ui/async-await/async-drop/type-parameter.rs
@@ -0,0 +1,16 @@
+//@ edition: 2024
+// ex-ice: #140500
+#![crate_type = "lib"]
+#![feature(async_drop)]
+#![expect(incomplete_features)]
+use std::future::AsyncDrop;
+struct A;
+impl Drop for A {
+    fn drop(&mut self) {}
+}
+impl AsyncDrop for A {
+    fn drop(_wrong: impl Sized) {} //~ ERROR: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl
+}
+async fn bar() {
+    A;
+}
diff --git a/tests/ui/async-await/async-drop/type-parameter.stderr b/tests/ui/async-await/async-drop/type-parameter.stderr
new file mode 100644
index 00000000000..841576b839e
--- /dev/null
+++ b/tests/ui/async-await/async-drop/type-parameter.stderr
@@ -0,0 +1,11 @@
+error[E0186]: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl
+  --> $DIR/type-parameter.rs:12:5
+   |
+LL |     fn drop(_wrong: impl Sized) {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `self: Pin<&mut Self>` in impl
+   |
+   = note: `drop` from trait: `fn(Pin<&mut Self>) -> impl Future<Output = ()>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0186`.
diff --git a/tests/ui/async-await/async-drop/unexpected-sort.rs b/tests/ui/async-await/async-drop/unexpected-sort.rs
new file mode 100644
index 00000000000..659e21eb241
--- /dev/null
+++ b/tests/ui/async-await/async-drop/unexpected-sort.rs
@@ -0,0 +1,18 @@
+// Ex-ice: #140484
+//@ edition: 2024
+#![crate_type = "lib"]
+#![allow(incomplete_features)]
+#![allow(non_camel_case_types)]
+#![feature(async_drop)]
+use std::future::AsyncDrop;
+struct a;
+impl Drop for a { //~ ERROR: not all trait items implemented, missing: `drop`
+    fn b() {} //~ ERROR: method `b` is not a member of trait `Drop`
+}
+impl AsyncDrop for a { //~ ERROR: not all trait items implemented, missing: `drop`
+    type c = ();
+    //~^ ERROR: type `c` is not a member of trait `AsyncDrop`
+}
+async fn bar() {
+    a;
+}
diff --git a/tests/ui/async-await/async-drop/unexpected-sort.stderr b/tests/ui/async-await/async-drop/unexpected-sort.stderr
new file mode 100644
index 00000000000..a6e4f9fd573
--- /dev/null
+++ b/tests/ui/async-await/async-drop/unexpected-sort.stderr
@@ -0,0 +1,32 @@
+error[E0407]: method `b` is not a member of trait `Drop`
+  --> $DIR/unexpected-sort.rs:10:5
+   |
+LL |     fn b() {}
+   |     ^^^^^^^^^ not a member of trait `Drop`
+
+error[E0437]: type `c` is not a member of trait `AsyncDrop`
+  --> $DIR/unexpected-sort.rs:13:5
+   |
+LL |     type c = ();
+   |     ^^^^^^^^^^^^ not a member of trait `AsyncDrop`
+
+error[E0046]: not all trait items implemented, missing: `drop`
+  --> $DIR/unexpected-sort.rs:9:1
+   |
+LL | impl Drop for a {
+   | ^^^^^^^^^^^^^^^ missing `drop` in implementation
+   |
+   = help: implement the missing item: `fn drop(&mut self) { todo!() }`
+
+error[E0046]: not all trait items implemented, missing: `drop`
+  --> $DIR/unexpected-sort.rs:12:1
+   |
+LL | impl AsyncDrop for a {
+   | ^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
+   |
+   = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0046, E0407, E0437.
+For more information about an error, try `rustc --explain E0046`.