@@ -724,7 +724,7 @@ impl<T: ?Sized> *const T {
724724 /// that their safety preconditions are met:
725725 /// ```rust
726726 /// # 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
728728 /// # &&
729729 /// origin.add(count) == ptr
730730 /// # &&
@@ -755,20 +755,20 @@ impl<T: ?Sized> *const T {
755755 /// let ptr1: *const i32 = &a[1];
756756 /// let ptr2: *const i32 = &a[3];
757757 /// unsafe {
758- /// assert_eq!(ptr2.sub_ptr (ptr1), 2);
758+ /// assert_eq!(ptr2.offset_from_unsigned (ptr1), 2);
759759 /// assert_eq!(ptr1.add(2), ptr2);
760760 /// assert_eq!(ptr2.sub(2), ptr1);
761- /// assert_eq!(ptr2.sub_ptr (ptr2), 0);
761+ /// assert_eq!(ptr2.offset_from_unsigned (ptr2), 0);
762762 /// }
763763 ///
764764 /// // This would be incorrect, as the pointers are not correctly ordered:
765- /// // ptr1.sub_ptr (ptr2)
765+ /// // ptr1.offset_from_unsigned (ptr2)
766766 /// ```
767767 #[ stable( feature = "ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
768768 #[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
769769 #[ inline]
770770 #[ 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
772772 where
773773 T : Sized ,
774774 {
@@ -786,7 +786,7 @@ impl<T: ?Sized> *const T {
786786
787787 ub_checks:: assert_unsafe_precondition!(
788788 check_language_ub,
789- "ptr::sub_ptr requires `self >= origin`" ,
789+ "ptr::offset_from_unsigned requires `self >= origin`" ,
790790 (
791791 this: * const ( ) = self as * const ( ) ,
792792 origin: * const ( ) = origin as * const ( ) ,
@@ -804,7 +804,7 @@ impl<T: ?Sized> *const T {
804804 /// units of **bytes**.
805805 ///
806806 /// 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
808808 /// documentation and safety requirements.
809809 ///
810810 /// For non-`Sized` pointees this operation considers only the data pointers,
@@ -813,9 +813,9 @@ impl<T: ?Sized> *const T {
813813 #[ rustc_const_stable( feature = "const_ptr_sub_ptr" , since = "CURRENT_RUSTC_VERSION" ) ]
814814 #[ inline]
815815 #[ 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 {
817817 // 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 > ( ) ) }
819819 }
820820
821821 /// Returns whether two pointers are guaranteed to be equal.
0 commit comments