1 // This returns a miri pointer at type usize, if the argument is a proper pointer
2 fn transmute_ptr_to_int<T>(x: *const T) -> usize {
3 unsafe { std::mem::transmute(x) }
7 // Some casting-to-int with arithmetic.
8 let x = &42 as *const i32 as usize;
11 let z = y as u8 as usize;
12 assert_eq!(z, y % 256);
14 // Pointer string formatting! We can't check the output as it changes when libstd changes,
15 // but we can make sure Miri does not error.
16 format!("{:?}", &mut 13 as *mut _);
18 // Check that intptrcast is triggered for explicit casts and that it is consistent with
20 let a: *const i32 = &42;
21 let b = transmute_ptr_to_int(a) as u8;
22 let c = a as usize as u8;