From: Simon Sapin Date: Wed, 27 Dec 2017 21:53:27 +0000 (+0100) Subject: Remove `Box::from_non_null_raw` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=8ef5e549c3cec025c6b7c37931bddd68f2fcab4a;p=rust.git Remove `Box::from_non_null_raw` Per https://github.com/rust-lang/rust/pull/46952#issuecomment-353956225 --- diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index a1563483f1e..60998bc677b 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -272,34 +272,6 @@ pub unsafe fn from_raw(raw: *mut T) -> Self { Box(Unique::new_unchecked(raw)) } - /// Constructs a `Box` from a `NonNull` pointer. - /// - /// After calling this function, the memory is owned by a `Box` and `T` can - /// then be destroyed and released upon drop. - /// - /// # Safety - /// - /// A `NonNull` can be safely created via [`NonNull::new`] and thus doesn't - /// necessarily own the data pointed to nor is the data guaranteed to live - /// as long as the pointer. - /// - /// [`NonNull::new`]: ../../core/ptr/struct.NonNull.html#method.new - /// - /// # Examples - /// - /// ``` - /// fn main() { - /// let x = Box::new(5); - /// let ptr = Box::into_non_null_raw(x); - /// let x = unsafe { Box::from_non_null_raw(ptr) }; - /// } - /// ``` - #[stable(feature = "nonnull", since = "1.24.0")] - #[inline] - pub unsafe fn from_non_null_raw(u: NonNull) -> Self { - Box(u.into()) - } - /// Consumes the `Box`, returning the wrapped raw pointer. /// /// After calling this function, the caller is responsible for the @@ -331,19 +303,15 @@ pub fn into_raw(b: Box) -> *mut T { /// After calling this function, the caller is responsible for the /// memory previously managed by the `Box`. In particular, the /// caller should properly destroy `T` and release the memory. The - /// proper way to do so is to either convert the `NonNull` pointer: - /// - /// - Into a `Box` with the [`Box::from_non_null_raw`] function. - /// - /// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`] - /// function. + /// proper way to do so is to convert the `NonNull` pointer + /// into a raw pointer and back into a `Box` with the [`Box::from_raw`] + /// function. /// /// Note: this is an associated function, which means that you have /// to call it as `Box::into_non_null_raw(b)` /// instead of `b.into_non_null_raw()`. This /// is so that there is no conflict with a method on the inner type. /// - /// [`Box::from_non_null_raw`]: struct.Box.html#method.from_non_null_raw /// [`Box::from_raw`]: struct.Box.html#method.from_raw /// /// # Examples