Closed
Description
The pointer to integer cast has an implicit side effect of exposing the provenance, so it cannot be removed under strict provenance model.
Example of an incorrect transformation:
pub fn expose_addr<T>(a: &T) {
a as *const T as usize;
}
-// MIR for `expose_addr` before SimplifyLocals
+// MIR for `expose_addr` after SimplifyLocals
fn expose_addr(_1: &T) -> () {
debug a => _1; // in scope 0 at a.rs:1:23: 1:24
let mut _0: (); // return place in scope 0 at a.rs:1:30: 1:30
- let _2: usize; // in scope 0 at a.rs:2:5: 2:27
- let mut _3: *const T; // in scope 0 at a.rs:2:5: 2:18
bb0: {
- _3 = &raw const (*_1); // scope 0 at a.rs:2:5: 2:6
- _2 = move _3 as usize (Misc); // scope 0 at a.rs:2:5: 2:27
return; // scope 0 at a.rs:3:2: 3:2
}
}