about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/core_simd/src/elements/const_ptr.rs14
-rw-r--r--crates/core_simd/src/elements/mut_ptr.rs14
2 files changed, 18 insertions, 10 deletions
diff --git a/crates/core_simd/src/elements/const_ptr.rs b/crates/core_simd/src/elements/const_ptr.rs
index 5a5faad23c8..3485d31e44d 100644
--- a/crates/core_simd/src/elements/const_ptr.rs
+++ b/crates/core_simd/src/elements/const_ptr.rs
@@ -83,17 +83,21 @@ where
 
     #[inline]
     fn addr(self) -> Self::Usize {
-        // Safety: Since `addr` discards provenance, this is safe.
+        // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
+        // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
+        // provenance).
         unsafe { core::mem::transmute_copy(&self) }
-
-        //TODO switch to casts when available
-        //self.cast()
     }
 
     #[inline]
-    fn with_addr(self, addr: Self::Usize) -> Self {
+    fn with_addr(self, _addr: Self::Usize) -> Self {
         unimplemented!()
         /*
+        // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
+        //
+        // In the mean-time, this operation is defined to be "as if" it was
+        // a wrapping_offset, so we can emulate it as such. This should properly
+        // restore pointer provenance even under today's compiler.
         self.cast::<*const u8>()
             .wrapping_offset(addr.cast::<isize>() - self.addr().cast::<isize>())
             .cast()
diff --git a/crates/core_simd/src/elements/mut_ptr.rs b/crates/core_simd/src/elements/mut_ptr.rs
index d7b05af0eac..39fe9f35621 100644
--- a/crates/core_simd/src/elements/mut_ptr.rs
+++ b/crates/core_simd/src/elements/mut_ptr.rs
@@ -78,17 +78,21 @@ where
 
     #[inline]
     fn addr(self) -> Self::Usize {
-        // Safety: Since `addr` discards provenance, this is safe.
+        // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
+        // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
+        // provenance).
         unsafe { core::mem::transmute_copy(&self) }
-
-        //TODO switch to casts when available
-        //self.cast()
     }
 
     #[inline]
-    fn with_addr(self, addr: Self::Usize) -> Self {
+    fn with_addr(self, _addr: Self::Usize) -> Self {
         unimplemented!()
         /*
+        // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
+        //
+        // In the mean-time, this operation is defined to be "as if" it was
+        // a wrapping_offset, so we can emulate it as such. This should properly
+        // restore pointer provenance even under today's compiler.
         self.cast::<*mut u8>()
             .wrapping_offset(addr.cast::<isize>() - self.addr().cast::<isize>())
             .cast()