about summary refs log tree commit diff
path: root/tests/ui/unsafe
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-05-23 09:44:22 +0000
committerMichael Goulet <michael@errs.io>2025-05-23 10:43:21 +0000
commit11392f4978fe3a81a87e4fd8abcb78a0dcf166e5 (patch)
treeccbf91fbce58e381cb9a0a1116cf4cbb6bc86849 /tests/ui/unsafe
parent52bf0cf795dfecc8b929ebb1c1e2545c3f41d4c9 (diff)
downloadrust-11392f4978fe3a81a87e4fd8abcb78a0dcf166e5.tar.gz
rust-11392f4978fe3a81a87e4fd8abcb78a0dcf166e5.zip
Emit dummy open drop for unsafe binder
Diffstat (limited to 'tests/ui/unsafe')
-rw-r--r--tests/ui/unsafe/move-out-of-non-copy.rs15
-rw-r--r--tests/ui/unsafe/move-out-of-non-copy.stderr14
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/unsafe/move-out-of-non-copy.rs b/tests/ui/unsafe/move-out-of-non-copy.rs
new file mode 100644
index 00000000000..ca6bf4277a1
--- /dev/null
+++ b/tests/ui/unsafe/move-out-of-non-copy.rs
@@ -0,0 +1,15 @@
+//@ compile-flags: -Zvalidate-mir
+
+// Regression test for <https://github.com/rust-lang/rust/issues/141394>.
+
+#![feature(unsafe_binders)]
+#![allow(incomplete_features)]
+
+use std::unsafe_binder::unwrap_binder;
+
+fn id<T>(x: unsafe<> T) -> T {
+    //~^ ERROR the trait bound `T: Copy` is not satisfied
+    unsafe { unwrap_binder!(x) }
+}
+
+fn main() {}
diff --git a/tests/ui/unsafe/move-out-of-non-copy.stderr b/tests/ui/unsafe/move-out-of-non-copy.stderr
new file mode 100644
index 00000000000..4598742c92b
--- /dev/null
+++ b/tests/ui/unsafe/move-out-of-non-copy.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `T: Copy` is not satisfied
+  --> $DIR/move-out-of-non-copy.rs:10:13
+   |
+LL | fn id<T>(x: unsafe<> T) -> T {
+   |             ^^^^^^^^^^ the trait `Copy` is not implemented for `T`
+   |
+help: consider restricting type parameter `T` with trait `Copy`
+   |
+LL | fn id<T: std::marker::Copy>(x: unsafe<> T) -> T {
+   |        +++++++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.