]>
Commit | Line | Data |
---|---|---|
064997fb FG |
1 | //! Validity must be satisfiable, even if validity is assumed. |
2 | ||
3 | #![crate_type = "lib"] | |
4 | #![feature(transmutability)] | |
5 | #![allow(dead_code, incomplete_features, non_camel_case_types)] | |
6 | ||
7 | mod assert { | |
f2b60f7d | 8 | use std::mem::{Assume, BikeshedIntrinsicFrom}; |
064997fb FG |
9 | pub struct Context; |
10 | ||
11 | pub fn is_maybe_transmutable<Src, Dst>() | |
12 | where | |
f2b60f7d | 13 | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }> |
064997fb FG |
14 | {} |
15 | } | |
16 | ||
17 | #[derive(Clone, Copy)] #[repr(u8)] enum Ox00 { V = 0x00 } | |
18 | #[derive(Clone, Copy)] #[repr(u8)] enum Ox01 { V = 0x01 } | |
19 | #[derive(Clone, Copy)] #[repr(u8)] enum OxFF { V = 0xFF } | |
20 | ||
21 | fn test() { | |
22 | #[repr(C)] | |
23 | union A { | |
24 | a: Ox00, | |
25 | b: OxFF, | |
26 | } | |
27 | ||
28 | #[repr(C)] | |
29 | union B { | |
30 | c: Ox01, | |
31 | } | |
32 | ||
33 | assert::is_maybe_transmutable::<A, B>(); //~ ERROR cannot be safely transmuted | |
34 | assert::is_maybe_transmutable::<B, A>(); //~ ERROR cannot be safely transmuted | |
35 | } |