// stderr-per-bitwidth //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. use std::mem; #[repr(C)] union MaybeUninit { uninit: (), init: T, } impl MaybeUninit { const fn new(t: T) -> Self { MaybeUninit { init: t } } } const UNINIT_INT_0: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value //~| invalid value at [0] mem::transmute([MaybeUninit { uninit: () }, MaybeUninit::new(1), MaybeUninit::new(2)]) }; const UNINIT_INT_1: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value //~| invalid value at [1] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(1u8), MaybeUninit { uninit: () }, MaybeUninit::new(1u8), MaybeUninit::new(1u8), MaybeUninit::new(2u8), MaybeUninit::new(2u8), MaybeUninit { uninit: () }, MaybeUninit::new(2u8), ]) }; const UNINIT_INT_2: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value //~| invalid value at [2] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(0u8), MaybeUninit::new(1u8), MaybeUninit::new(1u8), MaybeUninit::new(1u8), MaybeUninit::new(1u8), MaybeUninit::new(2u8), MaybeUninit::new(2u8), MaybeUninit::new(2u8), MaybeUninit { uninit: () }, ]) }; fn main() {}