Update comment on pointer-to-usize transmute
Co-authored-by: Ralf Jung <post@ralfj.de>
This commit is contained in:
parent
3d7e9c4b7f
commit
e90d15b247
@ -1652,9 +1652,10 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
|
|||||||
|
|
||||||
let stride = mem::size_of::<T>();
|
let stride = mem::size_of::<T>();
|
||||||
|
|
||||||
// SAFETY: At runtime, transmuting a pointer to `usize` is always safe, because they have the
|
// SAFETY: This is just an inlined `p.addr()` (which is not
|
||||||
// same layout. During const eval, we hook this function to ensure that the pointer always has
|
// a `const fn` so we cannot call it).
|
||||||
// an address (only the standard library can do this).
|
// During const eval, we hook this function to ensure that the pointer never
|
||||||
|
// has provenance, making this sound.
|
||||||
let addr: usize = unsafe { mem::transmute(p) };
|
let addr: usize = unsafe { mem::transmute(p) };
|
||||||
|
|
||||||
// SAFETY: `a` is a power-of-two, therefore non-zero.
|
// SAFETY: `a` is a power-of-two, therefore non-zero.
|
||||||
|
Loading…
Reference in New Issue
Block a user