]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/transmutability/unions/should_reject_intersecting.rs
1 //! ALL valid bit patterns of the source must be valid bit patterns of the
2 //! destination type, unless validity is assumed.
5 #![feature(transmutability)]
6 #![allow(dead_code, incomplete_features, non_camel_case_types)]
9 use std
::mem
::BikeshedIntrinsicFrom
;
12 pub fn is_transmutable
<Src
, Dst
>()
14 Dst
: BikeshedIntrinsicFrom
<Src
, Context
, false, false, false, true>
15 // validity is NOT assumed ----------------------------^^^^^
19 #[derive(Clone, Copy)] #[repr(u8)] enum Ox00 { V = 0x00 }
20 #[derive(Clone, Copy)] #[repr(u8)] enum Ox7F { V = 0x7F }
21 #[derive(Clone, Copy)] #[repr(u8)] enum OxFF { V = 0xFF }
36 assert
::is_transmutable
::<A
, B
>(); //~ ERROR cannot be safely transmuted
37 assert
::is_transmutable
::<B
, A
>(); //~ ERROR cannot be safely transmuted