]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / const_raw_ptr_ops2.rs
1 #![feature(const_raw_ptr_to_usize_cast, const_raw_ptr_deref)]
2
3 fn main() {}
4
5 // unconst and fine
6 const Y: usize = unsafe { 42usize as *const i32 as usize + 1 };
7 // unconst and bad, will thus error in miri
8 const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this
9 //~| WARN this was previously accepted by the compiler but is being phased out
10 // unconst and fine
11 const Z: i32 = unsafe { *(&1 as *const i32) };
12 // unconst and bad, will thus error in miri
13 const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause
14 //~| WARN this was previously accepted by the compiler but is being phased out
15 const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause
16 //~| WARN this was previously accepted by the compiler but is being phased out