]> git.lizzy.rs Git - rust.git/commitdiff
addr no longer exposes :)
authorRalf Jung <post@ralfj.de>
Fri, 3 Jun 2022 12:47:00 +0000 (08:47 -0400)
committerRalf Jung <post@ralfj.de>
Mon, 6 Jun 2022 15:43:25 +0000 (11:43 -0400)
tests/fail/provenance/ptr_int_unexposed.rs

index 8a336e43ba18fa1c9299cb88e0b34e9003ae1595..310024c1efc70d64c2c238f67beff502f2353ee9 100644 (file)
@@ -1,12 +1,12 @@
-// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows -Zmiri-allow-ptr-int-transmute
+// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows
+#![feature(strict_provenance)]
 
 fn main() {
     let x: i32 = 3;
     let x_ptr = &x as *const i32;
 
-    // TODO: switch this to addr() once we intrinsify it
-    let x_usize: usize = unsafe { std::mem::transmute(x_ptr) };
-    // Cast back a pointer that did *not* get exposed.
-    let ptr = x_usize as *const i32;
+    let x_usize: usize = x_ptr.addr();
+    // Cast back an address that did *not* get exposed.
+    let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
     assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed
 }