From 9a12d9a243070c8ac5f924dcaebd29a2ab0ef168 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 11 Jul 2020 16:35:48 +0200 Subject: [PATCH] fix dead links to wrapping_offset_from --- library/core/src/ptr/const_ptr.rs | 9 ++------- library/core/src/ptr/mut_ptr.rs | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 4b776e128ea..cc5e193852c 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -240,8 +240,8 @@ impl *const T { /// different allocated object. Note that in Rust, /// every (stack-allocated) variable is considered a separate allocated object. /// - /// In other words, `x.wrapping_offset(y.wrapping_offset_from(x))` is - /// *not* the same as `y`, and dereferencing it is undefined behavior + /// In other words, `x.wrapping_offset((y as usize).wrapping_sub(x as usize) / size_of::())` + /// is *not* the same as `y`, and dereferencing it is undefined behavior /// unless `x` and `y` point into the same allocated object. /// /// Compared to [`offset`], this method basically delays the requirement of staying @@ -292,7 +292,6 @@ impl *const T { /// This function is the inverse of [`offset`]. /// /// [`offset`]: #method.offset - /// [`wrapping_offset_from`]: #method.wrapping_offset_from /// /// # Safety /// @@ -326,10 +325,6 @@ impl *const T { /// Extension. As such, memory acquired directly from allocators or memory /// mapped files *may* be too large to handle with this function. /// - /// Consider using [`wrapping_offset_from`] instead if these constraints are - /// difficult to satisfy. The only advantage of this method is that it - /// enables more aggressive compiler optimizations. - /// /// # Panics /// /// This function panics if `T` is a Zero-Sized Type ("ZST"). diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index c3a818e4b3f..c85a3a50543 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -246,8 +246,8 @@ impl *mut T { /// different allocated object. Note that in Rust, /// every (stack-allocated) variable is considered a separate allocated object. /// - /// In other words, `x.wrapping_offset(y.wrapping_offset_from(x))` is - /// *not* the same as `y`, and dereferencing it is undefined behavior + /// In other words, `x.wrapping_offset((y as usize).wrapping_sub(x as usize) / size_of::())` + /// is *not* the same as `y`, and dereferencing it is undefined behavior /// unless `x` and `y` point into the same allocated object. /// /// Compared to [`offset`], this method basically delays the requirement of staying @@ -463,7 +463,6 @@ impl *mut T { /// This function is the inverse of [`offset`]. /// /// [`offset`]: #method.offset-1 - /// [`wrapping_offset_from`]: #method.wrapping_offset_from-1 /// /// # Safety /// @@ -497,10 +496,6 @@ impl *mut T { /// Extension. As such, memory acquired directly from allocators or memory /// mapped files *may* be too large to handle with this function. /// - /// Consider using [`wrapping_offset_from`] instead if these constraints are - /// difficult to satisfy. The only advantage of this method is that it - /// enables more aggressive compiler optimizations. - /// /// # Panics /// /// This function panics if `T` is a Zero-Sized Type ("ZST").