implement ptr.addr() via transmute
This commit is contained in:
parent
5e6bb83268
commit
4291332175
@ -180,7 +180,9 @@ impl<T: ?Sized> *const T {
|
|||||||
T: Sized,
|
T: Sized,
|
||||||
{
|
{
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// 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
|
/// 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,
|
T: Sized,
|
||||||
{
|
{
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// 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
|
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
|
||||||
|
Loading…
x
Reference in New Issue
Block a user