Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
This commit is contained in:
commit
e9ef8e1efa
51 changed files with 120 additions and 113 deletions
|
|
@ -4,7 +4,7 @@ error: strict provenance disallows casting integer `usize` to pointer `*const u8
|
|||
LL | let dangling = 16_usize as *const u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::from_exposed_addr()` instead
|
||||
= help: if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-strict-provenance-fuzzy-casts.rs:2:9
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
extern "rust-intrinsic" {
|
||||
fn simd_cast_ptr<T, U>(x: T) -> U;
|
||||
fn simd_expose_addr<T, U>(x: T) -> U;
|
||||
fn simd_from_exposed_addr<T, U>(x: T) -> U;
|
||||
fn simd_with_exposed_provenance<T, U>(x: T) -> U;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
@ -24,10 +24,10 @@ fn main() {
|
|||
|
||||
let exposed_addr: V<usize> = simd_expose_addr(const_ptrs);
|
||||
|
||||
let from_exposed_addr: V<*mut i8> = simd_from_exposed_addr(exposed_addr);
|
||||
let with_exposed_provenance: V<*mut i8> = simd_with_exposed_provenance(exposed_addr);
|
||||
|
||||
assert!(const_ptrs.0 == [ptr as *const u8, core::ptr::null()]);
|
||||
assert!(exposed_addr.0 == [ptr as usize, 0]);
|
||||
assert!(from_exposed_addr.0 == ptrs.0);
|
||||
assert!(with_exposed_provenance.0 == ptrs.0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue