Rollup merge of #73580 - RalfJung:deprecate-wrapping-offset-from, r=Amanieu

deprecate wrapping_offset_from

As per https://github.com/rust-lang/rust/issues/41079#issuecomment-433140733 which seems like a consensus.

r? @Amanieu
This commit is contained in:
Dylan DPC 2020-06-22 14:53:52 +02:00 committed by GitHub
commit 35ecb26297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -330,6 +330,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

View file

@ -380,11 +380,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)
}