Skip to content

Commit 7ad4369

Browse files
committed
remove deprecated wrapping_offset_from
1 parent 1241f19 commit 7ad4369

File tree

2 files changed

+0
-103
lines changed

2 files changed

+0
-103
lines changed

library/core/src/ptr/const_ptr.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -445,59 +445,6 @@ impl<T: ?Sized> *const T {
445445
intrinsics::ptr_guaranteed_ne(self, other)
446446
}
447447

448-
/// Calculates the distance between two pointers. The returned value is in
449-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
450-
///
451-
/// If the address different between the two pointers is not a multiple of
452-
/// `mem::size_of::<T>()` then the result of the division is rounded towards
453-
/// zero.
454-
///
455-
/// Though this method is safe for any two pointers, note that its result
456-
/// will be mostly useless if the two pointers aren't into the same allocated
457-
/// object, for example if they point to two different local variables.
458-
///
459-
/// # Panics
460-
///
461-
/// This function panics if `T` is a zero-sized type.
462-
///
463-
/// # Examples
464-
///
465-
/// Basic usage:
466-
///
467-
/// ```
468-
/// #![feature(ptr_wrapping_offset_from)]
469-
///
470-
/// let a = [0; 5];
471-
/// let ptr1: *const i32 = &a[1];
472-
/// let ptr2: *const i32 = &a[3];
473-
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
474-
/// assert_eq!(ptr1.wrapping_offset_from(ptr2), -2);
475-
/// assert_eq!(ptr1.wrapping_offset(2), ptr2);
476-
/// assert_eq!(ptr2.wrapping_offset(-2), ptr1);
477-
///
478-
/// let ptr1: *const i32 = 3 as _;
479-
/// let ptr2: *const i32 = 13 as _;
480-
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
481-
/// ```
482-
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
483-
#[rustc_deprecated(
484-
since = "1.46.0",
485-
reason = "Pointer distances across allocation \
486-
boundaries are not typically meaningful. \
487-
Use integer subtraction if you really need this."
488-
)]
489-
#[inline]
490-
pub fn wrapping_offset_from(self, origin: *const T) -> isize
491-
where
492-
T: Sized,
493-
{
494-
let pointee_size = mem::size_of::<T>();
495-
assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
496-
497-
let d = isize::wrapping_sub(self as _, origin as _);
498-
d.wrapping_div(pointee_size as _)
499-
}
500-
501448
/// Calculates the offset from a pointer (convenience for `.offset(count as isize)`).
502449
///
503450
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer

library/core/src/ptr/mut_ptr.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -552,56 +552,6 @@ impl<T: ?Sized> *mut T {
552552
unsafe { (self as *const T).offset_from(origin) }
553553
}
554554

555-
/// Calculates the distance between two pointers. The returned value is in
556-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
557-
///
558-
/// If the address different between the two pointers is not a multiple of
559-
/// `mem::size_of::<T>()` then the result of the division is rounded towards
560-
/// zero.
561-
///
562-
/// Though this method is safe for any two pointers, note that its result
563-
/// will be mostly useless if the two pointers aren't into the same allocated
564-
/// object, for example if they point to two different local variables.
565-
///
566-
/// # Panics
567-
///
568-
/// This function panics if `T` is a zero-sized type.
569-
///
570-
/// # Examples
571-
///
572-
/// Basic usage:
573-
///
574-
/// ```
575-
/// #![feature(ptr_wrapping_offset_from)]
576-
///
577-
/// let mut a = [0; 5];
578-
/// let ptr1: *mut i32 = &mut a[1];
579-
/// let ptr2: *mut i32 = &mut a[3];
580-
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
581-
/// assert_eq!(ptr1.wrapping_offset_from(ptr2), -2);
582-
/// assert_eq!(ptr1.wrapping_offset(2), ptr2);
583-
/// assert_eq!(ptr2.wrapping_offset(-2), ptr1);
584-
///
585-
/// let ptr1: *mut i32 = 3 as _;
586-
/// let ptr2: *mut i32 = 13 as _;
587-
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
588-
/// ```
589-
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
590-
#[rustc_deprecated(
591-
since = "1.46.0",
592-
reason = "Pointer distances across allocation \
593-
boundaries are not typically meaningful. \
594-
Use integer subtraction if you really need this."
595-
)]
596-
#[inline]
597-
pub fn wrapping_offset_from(self, origin: *const T) -> isize
598-
where
599-
T: Sized,
600-
{
601-
#[allow(deprecated_in_future, deprecated)]
602-
(self as *const T).wrapping_offset_from(origin)
603-
}
604-
605555
/// Calculates the offset from a pointer (convenience for `.offset(count as isize)`).
606556
///
607557
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer

0 commit comments

Comments
 (0)