about summary refs log tree commit diff
path: root/tests/ui/unsafe-binders
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-31 02:04:10 +0000
committerMichael Goulet <michael@errs.io>2025-01-31 17:40:28 +0000
commitb63341e892447f73888f858052bca57495ee8d67 (patch)
tree33f254d4c70018d8fd6d232f904c2c682e10a78a /tests/ui/unsafe-binders
parentfc1a9186dcdad111fd99ddd38bd961a8a205c380 (diff)
downloadrust-b63341e892447f73888f858052bca57495ee8d67.tar.gz
rust-b63341e892447f73888f858052bca57495ee8d67.zip
Enforce unsafe binders must be Copy (for now)
Diffstat (limited to 'tests/ui/unsafe-binders')
-rw-r--r--tests/ui/unsafe-binders/moves.rs15
-rw-r--r--tests/ui/unsafe-binders/moves.stderr98
2 files changed, 74 insertions, 39 deletions
diff --git a/tests/ui/unsafe-binders/moves.rs b/tests/ui/unsafe-binders/moves.rs
index 1f61d2bf144..5bfcee62402 100644
--- a/tests/ui/unsafe-binders/moves.rs
+++ b/tests/ui/unsafe-binders/moves.rs
@@ -1,17 +1,20 @@
+//@ known-bug: unknown
+
 #![feature(unsafe_binders)]
-//~^ WARN the feature `unsafe_binders` is incomplete
+// FIXME(unsafe_binders) ~^ WARN the feature `unsafe_binders` is incomplete
 
 use std::unsafe_binder::{wrap_binder, unwrap_binder};
-use std::mem::drop;
+use std::mem::{drop, ManuallyDrop};
 
-struct NotCopy;
+struct NotCopyInner;
+type NotCopy = ManuallyDrop<NotCopyInner>;
 
 fn use_after_wrap() {
     unsafe {
         let base = NotCopy;
         let binder: unsafe<> NotCopy = wrap_binder!(base);
         drop(base);
-        //~^ ERROR use of moved value: `base`
+        // FIXME(unsafe_binders) ~^ ERROR use of moved value: `base`
     }
 }
 
@@ -20,7 +23,7 @@ fn move_out_of_wrap() {
         let binder: unsafe<> NotCopy = wrap_binder!(NotCopy);
         drop(unwrap_binder!(binder));
         drop(unwrap_binder!(binder));
-        //~^ ERROR use of moved value: `binder`
+        // FIXME(unsafe_binders) ~^ ERROR use of moved value: `binder`
     }
 }
 
@@ -31,7 +34,7 @@ fn not_conflicting() {
         drop(unwrap_binder!(binder).1);
         // ^ NOT a problem.
         drop(unwrap_binder!(binder).0);
-        //~^ ERROR use of moved value: `binder.0`
+        // FIXME(unsafe_binders) ~^ ERROR use of moved value: `binder.0`
     }
 }
 
diff --git a/tests/ui/unsafe-binders/moves.stderr b/tests/ui/unsafe-binders/moves.stderr
index d90823bf7e2..ca507964008 100644
--- a/tests/ui/unsafe-binders/moves.stderr
+++ b/tests/ui/unsafe-binders/moves.stderr
@@ -1,5 +1,37 @@
+error[E0423]: expected value, found type alias `NotCopy`
+  --> $DIR/moves.rs:14:20
+   |
+LL |         let base = NotCopy;
+   |                    ^^^^^^^
+   |
+   = note: can't use a type alias as a constructor
+
+error[E0423]: expected value, found type alias `NotCopy`
+  --> $DIR/moves.rs:23:53
+   |
+LL |         let binder: unsafe<> NotCopy = wrap_binder!(NotCopy);
+   |                                                     ^^^^^^^
+   |
+   = note: can't use a type alias as a constructor
+
+error[E0423]: expected value, found type alias `NotCopy`
+  --> $DIR/moves.rs:32:65
+   |
+LL |         let binder: unsafe<> (NotCopy, NotCopy) = wrap_binder!((NotCopy, NotCopy));
+   |                                                                 ^^^^^^^
+   |
+   = note: can't use a type alias as a constructor
+
+error[E0423]: expected value, found type alias `NotCopy`
+  --> $DIR/moves.rs:32:74
+   |
+LL |         let binder: unsafe<> (NotCopy, NotCopy) = wrap_binder!((NotCopy, NotCopy));
+   |                                                                          ^^^^^^^
+   |
+   = note: can't use a type alias as a constructor
+
 warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/moves.rs:1:12
+  --> $DIR/moves.rs:3:12
    |
 LL | #![feature(unsafe_binders)]
    |            ^^^^^^^^^^^^^^
@@ -7,47 +39,47 @@ LL | #![feature(unsafe_binders)]
    = note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0382]: use of moved value: `base`
-  --> $DIR/moves.rs:13:14
+error[E0277]: the trait bound `NotCopyInner: Copy` is not satisfied
+  --> $DIR/moves.rs:15:21
    |
-LL |         let base = NotCopy;
-   |             ---- move occurs because `base` has type `NotCopy`, which does not implement the `Copy` trait
 LL |         let binder: unsafe<> NotCopy = wrap_binder!(base);
-   |                                                     ---- value moved here
-LL |         drop(base);
-   |              ^^^^ value used here after move
+   |                     ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopyInner`
    |
-note: if `NotCopy` implemented `Clone`, you could clone the value
-  --> $DIR/moves.rs:7:1
+   = note: required for `ManuallyDrop<NotCopyInner>` to implement `Copy`
+help: consider annotating `NotCopyInner` with `#[derive(Copy)]`
+   |
+LL + #[derive(Copy)]
+LL | struct NotCopyInner;
    |
-LL | struct NotCopy;
-   | ^^^^^^^^^^^^^^ consider implementing `Clone` for this type
-...
-LL |         let binder: unsafe<> NotCopy = wrap_binder!(base);
-   |                                                     ---- you could clone this value
 
-error[E0382]: use of moved value: `binder`
-  --> $DIR/moves.rs:22:14
+error[E0277]: the trait bound `NotCopyInner: Copy` is not satisfied
+  --> $DIR/moves.rs:23:21
+   |
+LL |         let binder: unsafe<> NotCopy = wrap_binder!(NotCopy);
+   |                     ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopyInner`
+   |
+   = note: required for `ManuallyDrop<NotCopyInner>` to implement `Copy`
+help: consider annotating `NotCopyInner` with `#[derive(Copy)]`
    |
-LL |         drop(unwrap_binder!(binder));
-   |              ---------------------- value moved here
-LL |         drop(unwrap_binder!(binder));
-   |              ^^^^^^^^^^^^^^^^^^^^^^ value used here after move
+LL + #[derive(Copy)]
+LL | struct NotCopyInner;
    |
-   = note: move occurs because `binder` has type `NotCopy`, which does not implement the `Copy` trait
-   = note: this error originates in the macro `unwrap_binder` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0382]: use of moved value: `binder.0`
-  --> $DIR/moves.rs:33:14
+error[E0277]: the trait bound `NotCopyInner: Copy` is not satisfied
+  --> $DIR/moves.rs:32:21
+   |
+LL |         let binder: unsafe<> (NotCopy, NotCopy) = wrap_binder!((NotCopy, NotCopy));
+   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopyInner`
+   |
+   = note: required for `ManuallyDrop<NotCopyInner>` to implement `Copy`
+   = note: required because it appears within the type `(ManuallyDrop<NotCopyInner>, ManuallyDrop<NotCopyInner>)`
+help: consider annotating `NotCopyInner` with `#[derive(Copy)]`
    |
-LL |         drop(unwrap_binder!(binder).0);
-   |              ------------------------ value moved here
-...
-LL |         drop(unwrap_binder!(binder).0);
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move
+LL + #[derive(Copy)]
+LL | struct NotCopyInner;
    |
-   = note: move occurs because `binder.0` has type `NotCopy`, which does not implement the `Copy` trait
 
-error: aborting due to 3 previous errors; 1 warning emitted
+error: aborting due to 7 previous errors; 1 warning emitted
 
-For more information about this error, try `rustc --explain E0382`.
+Some errors have detailed explanations: E0277, E0423.
+For more information about an error, try `rustc --explain E0277`.