implement ptr.addr() via transmute
This commit is contained in:
parent
5e6bb83268
commit
4291332175
2 changed files with 6 additions and 2 deletions
|
@ -180,7 +180,9 @@ impl<T: ?Sized> *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
|
||||
|
|
|
@ -184,7 +184,9 @@ impl<T: ?Sized> *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
|
||||
|
|
Loading…
Add table
Reference in a new issue