diff options
Diffstat (limited to 'tests/ui/transmutability/primitives/bool.rs')
-rw-r--r-- | tests/ui/transmutability/primitives/bool.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs new file mode 100644 index 000000000..eebb74fff --- /dev/null +++ b/tests/ui/transmutability/primitives/bool.rs @@ -0,0 +1,25 @@ +#![crate_type = "lib"] +#![feature(transmutability)] +#![allow(dead_code)] +#![allow(incomplete_features)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_transmutable<Src, Dst>() + where + Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> + {} + + pub fn is_maybe_transmutable<Src, Dst>() + where + Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }> + {} +} + +fn contrast_with_u8() { + assert::is_transmutable::<u8, bool>(); //~ ERROR cannot be safely transmuted + assert::is_maybe_transmutable::<u8, bool>(); + assert::is_transmutable::<bool, u8>(); +} |