@@ -857,7 +857,7 @@ impl<T: ?Sized> NonNull<T> {
857857 /// that their safety preconditions are met:
858858 /// ```rust
859859 /// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool { unsafe {
860- /// ptr.sub_ptr (origin) == count
860+ /// ptr.offset_from_unsigned (origin) == count
861861 /// # &&
862862 /// origin.add(count) == ptr
863863 /// # &&
@@ -890,25 +890,25 @@ impl<T: ?Sized> NonNull<T> {
890890 /// let ptr1: NonNull<u32> = NonNull::from(&a[1]);
891891 /// let ptr2: NonNull<u32> = NonNull::from(&a[3]);
892892 /// unsafe {
893- /// assert_eq!(ptr2.sub_ptr (ptr1), 2);
893+ /// assert_eq!(ptr2.offset_from_unsigned (ptr1), 2);
894894 /// assert_eq!(ptr1.add(2), ptr2);
895895 /// assert_eq!(ptr2.sub(2), ptr1);
896- /// assert_eq!(ptr2.sub_ptr (ptr2), 0);
896+ /// assert_eq!(ptr2.offset_from_unsigned (ptr2), 0);
897897 /// }
898898 ///
899899 /// // This would be incorrect, as the pointers are not correctly ordered:
900- /// // ptr1.sub_ptr (ptr2)
900+ /// // ptr1.offset_from_unsigned (ptr2)
901901 /// ```
902902 #[ inline]
903903 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
904904 #[ stable( feature = "ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
905905 #[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
906- pub const unsafe fn sub_ptr ( self , subtracted : NonNull < T > ) -> usize
906+ pub const unsafe fn offset_from_unsigned ( self , subtracted : NonNull < T > ) -> usize
907907 where
908908 T : Sized ,
909909 {
910910 // SAFETY: the caller must uphold the safety contract for `sub_ptr`.
911- unsafe { self . as_ptr ( ) . sub_ptr ( subtracted. as_ptr ( ) ) }
911+ unsafe { self . as_ptr ( ) . offset_from_unsigned ( subtracted. as_ptr ( ) ) }
912912 }
913913
914914 /// Calculates the distance between two pointers within the same allocation, *where it's known that
@@ -925,9 +925,9 @@ impl<T: ?Sized> NonNull<T> {
925925 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
926926 #[ stable( feature = "ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
927927 #[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
928- pub const unsafe fn byte_sub_ptr < U : ?Sized > ( self , origin : NonNull < U > ) -> usize {
928+ pub const unsafe fn byte_offset_from_unsigned < U : ?Sized > ( self , origin : NonNull < U > ) -> usize {
929929 // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`.
930- unsafe { self . as_ptr ( ) . byte_sub_ptr ( origin. as_ptr ( ) ) }
930+ unsafe { self . as_ptr ( ) . byte_offset_from_unsigned ( origin. as_ptr ( ) ) }
931931 }
932932
933933 /// Reads the value from `self` without moving it. This leaves the
0 commit comments