make ptr::invalid not the same as a regular int2ptr cast In Miri, we would like to distinguish `ptr::invalid` from `ptr::from_exposed_provenance`, so that we can provide better diagnostics issues like https://github.com/rust-lang/miri/issues/2134, and so that we can detect the UB in programs like ```rust fn main() { let x = 0u8; let original_ptr = &x as *const u8; let addr = original_ptr.expose_addr(); let new_ptr: *const u8 = core::ptr::invalid(addr); unsafe { dbg!(*new_ptr); } } ``` To achieve that, the two functions need to have different implementations. Currently, both are just `as` casts. We *could* add an intrinsic for this, but it turns out `transmute` already has the right behavior, at least as far as Miri is concerned. So I propose we just use that. Cc `@Gankra` |
||
|---|---|---|
| .. | ||
| benches | ||
| primitive_docs | ||
| src | ||
| tests | ||
| Cargo.toml | ||