Skip to content

Commit 91d0414

Browse files
authored
Rollup merge of rust-lang#73580 - RalfJung:deprecate-wrapping-offset-from, r=Amanieu
deprecate wrapping_offset_from As per rust-lang#41079 (comment) which seems like a consensus. r? @Amanieu
2 parents d1b1ca3 + 467415d commit 91d0414

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/libcore/ptr/const_ptr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ impl<T: ?Sized> *const T {
396396
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
397397
/// ```
398398
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
399+
#[rustc_deprecated(
400+
since = "1.46.0",
401+
reason = "Pointer distances across allocation \
402+
boundaries are not typically meaningful. \
403+
Use integer subtraction if you really need this."
404+
)]
399405
#[inline]
400406
pub fn wrapping_offset_from(self, origin: *const T) -> isize
401407
where

src/libcore/ptr/mut_ptr.rs

+7
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,18 @@ impl<T: ?Sized> *mut T {
446446
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
447447
/// ```
448448
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
449+
#[rustc_deprecated(
450+
since = "1.46.0",
451+
reason = "Pointer distances across allocation \
452+
boundaries are not typically meaningful. \
453+
Use integer subtraction if you really need this."
454+
)]
449455
#[inline]
450456
pub fn wrapping_offset_from(self, origin: *const T) -> isize
451457
where
452458
T: Sized,
453459
{
460+
#[allow(deprecated_in_future, deprecated)]
454461
(self as *const T).wrapping_offset_from(origin)
455462
}
456463

0 commit comments

Comments
 (0)