]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/miri_unleashed/ptr_arith.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / consts / miri_unleashed / ptr_arith.rs
1 // compile-flags: -Zunleash-the-miri-inside-of-you
2 #![feature(core_intrinsics)]
3 #![allow(const_err)]
4
5 // During CTFE, we prevent pointer comparison and pointer-to-int casts.
6
7 static CMP: () = {
8 let x = &0 as *const _;
9 let _v = x == x;
10 //~^ ERROR could not evaluate static initializer
11 //~| NOTE pointer arithmetic or comparison
12 };
13
14 static INT_PTR_ARITH: () = unsafe {
15 let x: usize = std::mem::transmute(&0);
16 let _v = x + 0;
17 //~^ ERROR could not evaluate static initializer
18 //~| NOTE cannot cast pointer to integer
19 };
20
21 fn main() {}