Rename sub_ptr to offset_from_unsigned in docs
This commit is contained in:
@@ -2996,7 +2996,7 @@ pub unsafe fn nontemporal_store<T>(ptr: *mut T, val: T);
|
||||
#[rustc_intrinsic]
|
||||
pub const unsafe fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;
|
||||
|
||||
/// See documentation of `<*const T>::sub_ptr` for details.
|
||||
/// See documentation of `<*const T>::offset_from_unsigned` for details.
|
||||
#[rustc_nounwind]
|
||||
#[rustc_intrinsic]
|
||||
#[rustc_intrinsic_const_stable_indirect]
|
||||
|
||||
@@ -804,8 +804,8 @@ impl<T: ?Sized> *const T {
|
||||
/// units of **bytes**.
|
||||
///
|
||||
/// This is purely a convenience for casting to a `u8` pointer and
|
||||
/// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for
|
||||
/// documentation and safety requirements.
|
||||
/// using [`offset_from_unsigned`][pointer::offset_from_unsigned] on it.
|
||||
/// See that method for documentation and safety requirements.
|
||||
///
|
||||
/// For non-`Sized` pointees this operation considers only the data pointers,
|
||||
/// ignoring the metadata.
|
||||
@@ -814,7 +814,7 @@ impl<T: ?Sized> *const T {
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset_from_unsigned<U: ?Sized>(self, origin: *const U) -> usize {
|
||||
// SAFETY: the caller must uphold the safety contract for `sub_ptr`.
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from_unsigned`.
|
||||
unsafe { self.cast::<u8>().offset_from_unsigned(origin.cast::<u8>()) }
|
||||
}
|
||||
|
||||
|
||||
@@ -937,6 +937,7 @@ impl<T: ?Sized> *mut T {
|
||||
///
|
||||
/// // This would be incorrect, as the pointers are not correctly ordered:
|
||||
/// // ptr1.offset_from(ptr2)
|
||||
/// ```
|
||||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
#[inline]
|
||||
@@ -945,7 +946,7 @@ impl<T: ?Sized> *mut T {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
// SAFETY: the caller must uphold the safety contract for `sub_ptr`.
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from_unsigned`.
|
||||
unsafe { (self as *const T).offset_from_unsigned(origin) }
|
||||
}
|
||||
|
||||
@@ -954,8 +955,8 @@ impl<T: ?Sized> *mut T {
|
||||
/// units of **bytes**.
|
||||
///
|
||||
/// This is purely a convenience for casting to a `u8` pointer and
|
||||
/// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for
|
||||
/// documentation and safety requirements.
|
||||
/// using [`offset_from_unsigned`][pointer::offset_from_unsigned] on it.
|
||||
/// See that method for documentation and safety requirements.
|
||||
///
|
||||
/// For non-`Sized` pointees this operation considers only the data pointers,
|
||||
/// ignoring the metadata.
|
||||
@@ -964,7 +965,7 @@ impl<T: ?Sized> *mut T {
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset_from_unsigned<U: ?Sized>(self, origin: *mut U) -> usize {
|
||||
// SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`.
|
||||
// SAFETY: the caller must uphold the safety contract for `byte_offset_from_unsigned`.
|
||||
unsafe { (self as *const T).byte_offset_from_unsigned(origin) }
|
||||
}
|
||||
|
||||
|
||||
@@ -906,7 +906,7 @@ impl<T: ?Sized> NonNull<T> {
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
// SAFETY: the caller must uphold the safety contract for `sub_ptr`.
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from_unsigned`.
|
||||
unsafe { self.as_ptr().offset_from_unsigned(subtracted.as_ptr()) }
|
||||
}
|
||||
|
||||
@@ -915,8 +915,8 @@ impl<T: ?Sized> NonNull<T> {
|
||||
/// units of **bytes**.
|
||||
///
|
||||
/// This is purely a convenience for casting to a `u8` pointer and
|
||||
/// using [`sub_ptr`][NonNull::offset_from_unsigned] on it. See that method for
|
||||
/// documentation and safety requirements.
|
||||
/// using [`offset_from_unsigned`][NonNull::offset_from_unsigned] on it.
|
||||
/// See that method for documentation and safety requirements.
|
||||
///
|
||||
/// For non-`Sized` pointees this operation considers only the data pointers,
|
||||
/// ignoring the metadata.
|
||||
@@ -925,7 +925,7 @@ impl<T: ?Sized> NonNull<T> {
|
||||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
pub const unsafe fn byte_offset_from_unsigned<U: ?Sized>(self, origin: NonNull<U>) -> usize {
|
||||
// SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`.
|
||||
// SAFETY: the caller must uphold the safety contract for `byte_offset_from_unsigned`.
|
||||
unsafe { self.as_ptr().byte_offset_from_unsigned(origin.as_ptr()) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user