@@ -35,7 +35,7 @@ impl<T: ?Sized> *const T {
35
35
pub const fn is_null ( self ) -> bool {
36
36
#[ inline]
37
37
fn runtime_impl ( ptr : * const u8 ) -> bool {
38
- ptr. addr ( ) == 0
38
+ ptr. addr_without_provenance ( ) == 0
39
39
}
40
40
41
41
#[ inline]
@@ -203,7 +203,7 @@ impl<T: ?Sized> *const T {
203
203
#[ must_use]
204
204
#[ inline( always) ]
205
205
#[ unstable( feature = "strict_provenance" , issue = "95228" ) ]
206
- pub fn addr ( self ) -> usize {
206
+ pub fn addr_without_provenance ( self ) -> usize {
207
207
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
208
208
// SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
209
209
// provenance).
@@ -223,7 +223,7 @@ impl<T: ?Sized> *const T {
223
223
/// Provenance][super#strict-provenance] rules. Supporting
224
224
/// [`from_exposed_addr`][] complicates specification and reasoning and may not be supported by
225
225
/// tools that help you to stay conformant with the Rust memory model, so it is recommended to
226
- /// use [`addr `][pointer::addr ] wherever possible.
226
+ /// use [`addr_without_provenance `][pointer::addr_without_provenance ] wherever possible.
227
227
///
228
228
/// On most platforms this will produce a value with the same bytes as the original pointer,
229
229
/// because all the bytes are dedicated to describing the address. Platforms which need to store
@@ -264,7 +264,7 @@ impl<T: ?Sized> *const T {
264
264
// In the mean-time, this operation is defined to be "as if" it was
265
265
// a wrapping_offset, so we can emulate it as such. This should properly
266
266
// restore pointer provenance even under today's compiler.
267
- let self_addr = self . addr ( ) as isize ;
267
+ let self_addr = self . addr_without_provenance ( ) as isize ;
268
268
let dest_addr = addr as isize ;
269
269
let offset = dest_addr. wrapping_sub ( self_addr) ;
270
270
@@ -282,7 +282,7 @@ impl<T: ?Sized> *const T {
282
282
#[ inline]
283
283
#[ unstable( feature = "strict_provenance" , issue = "95228" ) ]
284
284
pub fn map_addr ( self , f : impl FnOnce ( usize ) -> usize ) -> Self {
285
- self . with_addr ( f ( self . addr ( ) ) )
285
+ self . with_addr ( f ( self . addr_without_provenance ( ) ) )
286
286
}
287
287
288
288
/// Decompose a (possibly wide) pointer into its data pointer and metadata components.
@@ -592,7 +592,7 @@ impl<T: ?Sized> *const T {
592
592
/// let tagged_ptr = ptr.map_addr(|a| a | 0b10);
593
593
///
594
594
/// // Get the "tag" back
595
- /// let tag = tagged_ptr.addr () & tag_mask;
595
+ /// let tag = tagged_ptr.addr_without_provenance () & tag_mask;
596
596
/// assert_eq!(tag, 0b10);
597
597
///
598
598
/// // Note that `tagged_ptr` is unaligned, it's UB to read from it.
@@ -664,7 +664,7 @@ impl<T: ?Sized> *const T {
664
664
/// runtime and may be exploited by optimizations. If you wish to compute the difference between
665
665
/// pointers that are not guaranteed to be from the same allocation, use `(self as isize -
666
666
/// origin as isize) / mem::size_of::<T>()`.
667
- // FIXME: recommend `addr ()` instead of `as usize` once that is stable.
667
+ // FIXME: recommend `addr_without_provenance ()` instead of `as usize` once that is stable.
668
668
///
669
669
/// [`add`]: #method.add
670
670
/// [allocated object]: crate::ptr#allocated-object
@@ -1611,7 +1611,7 @@ impl<T: ?Sized> *const T {
1611
1611
1612
1612
#[ inline]
1613
1613
fn runtime_impl ( ptr : * const ( ) , align : usize ) -> bool {
1614
- ptr. addr ( ) & ( align - 1 ) == 0
1614
+ ptr. addr_without_provenance ( ) & ( align - 1 ) == 0
1615
1615
}
1616
1616
1617
1617
#[ inline]
0 commit comments