Skip to content

Commit

Permalink
Merge pull request #10 from RalfJung/addr
Browse files Browse the repository at this point in the history
use transmute for ptr.addr
  • Loading branch information
RalfJung authored Jun 8, 2022
2 parents 796f0f2 + 9373c80 commit 872e0f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ impl<T> Strict for *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 { core::mem::transmute(self) }
}

#[must_use]
Expand Down Expand Up @@ -658,7 +660,9 @@ impl<T> Strict for *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 { core::mem::transmute(self) }
}

#[must_use]
Expand Down

0 comments on commit 872e0f1

Please sign in to comment.