diff --git a/core/src/ptr/const_ptr.rs b/core/src/ptr/const_ptr.rs index f26fdc74c..490d7594b 100644 --- a/core/src/ptr/const_ptr.rs +++ b/core/src/ptr/const_ptr.rs @@ -180,7 +180,9 @@ impl *const T { T: Sized, { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. - self as usize + // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the + // provenance). + unsafe { mem::transmute(self) } } /// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future diff --git a/core/src/ptr/mut_ptr.rs b/core/src/ptr/mut_ptr.rs index 1fbf592c2..5846c855e 100644 --- a/core/src/ptr/mut_ptr.rs +++ b/core/src/ptr/mut_ptr.rs @@ -184,7 +184,9 @@ impl *mut T { T: Sized, { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. - self as usize + // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the + // provenance). + unsafe { mem::transmute(self) } } /// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future