1 #![feature(const_transmute)]
2 #![allow(const_err)] // make sure we cannot allow away the errors tested here
6 const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
7 //~^ ERROR it is undefined behavior to use this value
8 //~^^ type validation failed: encountered unaligned reference (required 2 alignment but found 1)
10 const NULL: &u16 = unsafe { mem::transmute(0usize) };
11 //~^ ERROR it is undefined behavior to use this value
13 const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
14 //~^ ERROR it is undefined behavior to use this value
16 const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
17 //~^ ERROR it is undefined behavior to use this value
19 const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
20 //~^ ERROR it is undefined behavior to use this value