@@ -724,7 +724,7 @@ impl<T: ?Sized> *const T {
724
724
/// that their safety preconditions are met:
725
725
/// ```rust
726
726
/// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe {
727
- /// ptr.sub_ptr (origin) == count
727
+ /// ptr.offset_from_unsigned (origin) == count
728
728
/// # &&
729
729
/// origin.add(count) == ptr
730
730
/// # &&
@@ -755,20 +755,20 @@ impl<T: ?Sized> *const T {
755
755
/// let ptr1: *const i32 = &a[1];
756
756
/// let ptr2: *const i32 = &a[3];
757
757
/// unsafe {
758
- /// assert_eq!(ptr2.sub_ptr (ptr1), 2);
758
+ /// assert_eq!(ptr2.offset_from_unsigned (ptr1), 2);
759
759
/// assert_eq!(ptr1.add(2), ptr2);
760
760
/// assert_eq!(ptr2.sub(2), ptr1);
761
- /// assert_eq!(ptr2.sub_ptr (ptr2), 0);
761
+ /// assert_eq!(ptr2.offset_from_unsigned (ptr2), 0);
762
762
/// }
763
763
///
764
764
/// // This would be incorrect, as the pointers are not correctly ordered:
765
- /// // ptr1.sub_ptr (ptr2)
765
+ /// // ptr1.offset_from_unsigned (ptr2)
766
766
/// ```
767
767
#[ stable( feature = "ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
768
768
#[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
769
769
#[ inline]
770
770
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
771
- pub const unsafe fn sub_ptr ( self , origin : * const T ) -> usize
771
+ pub const unsafe fn offset_from_unsigned ( self , origin : * const T ) -> usize
772
772
where
773
773
T : Sized ,
774
774
{
@@ -786,7 +786,7 @@ impl<T: ?Sized> *const T {
786
786
787
787
ub_checks:: assert_unsafe_precondition!(
788
788
check_language_ub,
789
- "ptr::sub_ptr requires `self >= origin`" ,
789
+ "ptr::offset_from_unsigned requires `self >= origin`" ,
790
790
(
791
791
this: * const ( ) = self as * const ( ) ,
792
792
origin: * const ( ) = origin as * const ( ) ,
@@ -804,7 +804,7 @@ impl<T: ?Sized> *const T {
804
804
/// units of **bytes**.
805
805
///
806
806
/// This is purely a convenience for casting to a `u8` pointer and
807
- /// using [`sub_ptr`][pointer::sub_ptr ] on it. See that method for
807
+ /// using [`sub_ptr`][pointer::offset_from_unsigned ] on it. See that method for
808
808
/// documentation and safety requirements.
809
809
///
810
810
/// For non-`Sized` pointees this operation considers only the data pointers,
@@ -813,9 +813,9 @@ impl<T: ?Sized> *const T {
813
813
#[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
814
814
#[ inline]
815
815
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
816
- pub const unsafe fn byte_sub_ptr < U : ?Sized > ( self , origin : * const U ) -> usize {
816
+ pub const unsafe fn byte_offset_from_unsigned < U : ?Sized > ( self , origin : * const U ) -> usize {
817
817
// SAFETY: the caller must uphold the safety contract for `sub_ptr`.
818
- unsafe { self . cast :: < u8 > ( ) . sub_ptr ( origin. cast :: < u8 > ( ) ) }
818
+ unsafe { self . cast :: < u8 > ( ) . offset_from_unsigned ( origin. cast :: < u8 > ( ) ) }
819
819
}
820
820
821
821
/// Returns whether two pointers are guaranteed to be equal.
0 commit comments