summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmutability/primitives
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/transmutability/primitives')
-rw-r--r--tests/ui/transmutability/primitives/bool-mut.rs17
-rw-r--r--tests/ui/transmutability/primitives/bool-mut.stderr18
-rw-r--r--tests/ui/transmutability/primitives/bool.current.stderr4
-rw-r--r--tests/ui/transmutability/primitives/bool.next.stderr4
-rw-r--r--tests/ui/transmutability/primitives/bool.rs5
5 files changed, 40 insertions, 8 deletions
diff --git a/tests/ui/transmutability/primitives/bool-mut.rs b/tests/ui/transmutability/primitives/bool-mut.rs
new file mode 100644
index 000000000..49dbe90e4
--- /dev/null
+++ b/tests/ui/transmutability/primitives/bool-mut.rs
@@ -0,0 +1,17 @@
+// check-fail
+//[next] compile-flags: -Ztrait-solver=next
+
+#![feature(transmutability)]
+mod assert {
+ use std::mem::{Assume, BikeshedIntrinsicFrom};
+ pub struct Context;
+
+ pub fn is_transmutable<Src, Dst>()
+ where
+ Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
+ {}
+}
+
+fn main() {
+ assert::is_transmutable::<&'static mut bool, &'static mut u8>() //~ ERROR cannot be safely transmuted
+}
diff --git a/tests/ui/transmutability/primitives/bool-mut.stderr b/tests/ui/transmutability/primitives/bool-mut.stderr
new file mode 100644
index 000000000..b36991e1c
--- /dev/null
+++ b/tests/ui/transmutability/primitives/bool-mut.stderr
@@ -0,0 +1,18 @@
+error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
+ --> $DIR/bool-mut.rs:16:50
+ |
+LL | assert::is_transmutable::<&'static mut bool, &'static mut u8>()
+ | ^^^^^^^^^^^^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
+ |
+note: required by a bound in `is_transmutable`
+ --> $DIR/bool-mut.rs:11:14
+ |
+LL | pub fn is_transmutable<Src, Dst>()
+ | --------------- required by a bound in this function
+LL | where
+LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/transmutability/primitives/bool.current.stderr b/tests/ui/transmutability/primitives/bool.current.stderr
index 47c8438a2..4b3eb6c51 100644
--- a/tests/ui/transmutability/primitives/bool.current.stderr
+++ b/tests/ui/transmutability/primitives/bool.current.stderr
@@ -1,11 +1,11 @@
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
- --> $DIR/bool.rs:24:35
+ --> $DIR/bool.rs:21:35
|
LL | assert::is_transmutable::<u8, bool>();
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
note: required by a bound in `is_transmutable`
- --> $DIR/bool.rs:14:14
+ --> $DIR/bool.rs:11:14
|
LL | pub fn is_transmutable<Src, Dst>()
| --------------- required by a bound in this function
diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr
index 47c8438a2..4b3eb6c51 100644
--- a/tests/ui/transmutability/primitives/bool.next.stderr
+++ b/tests/ui/transmutability/primitives/bool.next.stderr
@@ -1,11 +1,11 @@
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
- --> $DIR/bool.rs:24:35
+ --> $DIR/bool.rs:21:35
|
LL | assert::is_transmutable::<u8, bool>();
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
note: required by a bound in `is_transmutable`
- --> $DIR/bool.rs:14:14
+ --> $DIR/bool.rs:11:14
|
LL | pub fn is_transmutable<Src, Dst>()
| --------------- required by a bound in this function
diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs
index de77cfc78..654e7b47e 100644
--- a/tests/ui/transmutability/primitives/bool.rs
+++ b/tests/ui/transmutability/primitives/bool.rs
@@ -1,10 +1,7 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
-#![crate_type = "lib"]
#![feature(transmutability)]
-#![allow(dead_code)]
-#![allow(incomplete_features)]
mod assert {
use std::mem::{Assume, BikeshedIntrinsicFrom};
pub struct Context;
@@ -20,7 +17,7 @@ mod assert {
{}
}
-fn contrast_with_u8() {
+fn main() {
assert::is_transmutable::<u8, bool>(); //~ ERROR cannot be safely transmuted
assert::is_maybe_transmutable::<u8, bool>();
assert::is_transmutable::<bool, u8>();