Skip to content

Commit

Permalink
Rollup merge of rust-lang#73580 - RalfJung:deprecate-wrapping-offset-…
Browse files Browse the repository at this point in the history
…from, r=Amanieu

deprecate wrapping_offset_from

As per rust-lang#41079 (comment) which seems like a consensus.

r? @Amanieu
  • Loading branch information
Manishearth authored Jun 21, 2020
2 parents d1b1ca3 + 467415d commit 91d0414
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libcore/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ impl<T: ?Sized> *const T {
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
/// ```
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
#[rustc_deprecated(
since = "1.46.0",
reason = "Pointer distances across allocation \
boundaries are not typically meaningful. \
Use integer subtraction if you really need this."
)]
#[inline]
pub fn wrapping_offset_from(self, origin: *const T) -> isize
where
Expand Down
7 changes: 7 additions & 0 deletions src/libcore/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,18 @@ impl<T: ?Sized> *mut T {
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
/// ```
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
#[rustc_deprecated(
since = "1.46.0",
reason = "Pointer distances across allocation \
boundaries are not typically meaningful. \
Use integer subtraction if you really need this."
)]
#[inline]
pub fn wrapping_offset_from(self, origin: *const T) -> isize
where
T: Sized,
{
#[allow(deprecated_in_future, deprecated)]
(self as *const T).wrapping_offset_from(origin)
}

Expand Down

0 comments on commit 91d0414

Please sign in to comment.