Skip to content

Commit 35ecb26

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

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
@@ -330,6 +330,12 @@ impl<T: ?Sized> *const T {
330330
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
331331
/// ```
332332
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
333+
#[rustc_deprecated(
334+
since = "1.46.0",
335+
reason = "Pointer distances across allocation \
336+
boundaries are not typically meaningful. \
337+
Use integer subtraction if you really need this."
338+
)]
333339
#[inline]
334340
pub fn wrapping_offset_from(self, origin: *const T) -> isize
335341
where

src/libcore/ptr/mut_ptr.rs

+7
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,18 @@ impl<T: ?Sized> *mut T {
380380
/// assert_eq!(ptr2.wrapping_offset_from(ptr1), 2);
381381
/// ```
382382
#[unstable(feature = "ptr_wrapping_offset_from", issue = "41079")]
383+
#[rustc_deprecated(
384+
since = "1.46.0",
385+
reason = "Pointer distances across allocation \
386+
boundaries are not typically meaningful. \
387+
Use integer subtraction if you really need this."
388+
)]
383389
#[inline]
384390
pub fn wrapping_offset_from(self, origin: *const T) -> isize
385391
where
386392
T: Sized,
387393
{
394+
#[allow(deprecated_in_future, deprecated)]
388395
(self as *const T).wrapping_offset_from(origin)
389396
}
390397

0 commit comments

Comments
 (0)