@@ -42,6 +42,19 @@ pub trait SimdConstPtr: Copy + Sealed {
4242 /// Equivalent to calling [`pointer::addr`] on each element.
4343 fn addr ( self ) -> Self :: Usize ;
4444
45+ /// Convert an address to a pointer without giving it any provenance.
46+ ///
47+ /// Without provenance, this pointer is not associated with any actual allocation. Such a
48+ /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
49+ /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers
50+ /// are little more than a usize address in disguise.
51+ ///
52+ /// This is different from [`Self::from_exposed_addr`], which creates a pointer that picks up a
53+ /// previously exposed provenance.
54+ ///
55+ /// Equivalent to calling [`core::ptr::without_provenance`] on each element.
56+ fn without_provenance ( addr : Self :: Usize ) -> Self ;
57+
4558 /// Creates a new pointer with the given address.
4659 ///
4760 /// This performs the same operation as a cast, but copies the *address-space* and
@@ -118,6 +131,14 @@ where
118131 unsafe { core:: mem:: transmute_copy ( & self ) }
119132 }
120133
134+ #[ inline]
135+ fn without_provenance ( addr : Self :: Usize ) -> Self {
136+ // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
137+ // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any
138+ // provenance).
139+ unsafe { core:: mem:: transmute_copy ( & addr) }
140+ }
141+
121142 #[ inline]
122143 fn with_addr ( self , addr : Self :: Usize ) -> Self {
123144 // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
0 commit comments