Skip to content

Commit 8ef5e54

Browse files
committed
Remove Box::from_non_null_raw
Per rust-lang#46952 (comment)
1 parent 1772fa2 commit 8ef5e54

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

src/liballoc/boxed.rs

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -272,34 +272,6 @@ impl<T: ?Sized> Box<T> {
272272
Box(Unique::new_unchecked(raw))
273273
}
274274

275-
/// Constructs a `Box` from a `NonNull<T>` pointer.
276-
///
277-
/// After calling this function, the memory is owned by a `Box` and `T` can
278-
/// then be destroyed and released upon drop.
279-
///
280-
/// # Safety
281-
///
282-
/// A `NonNull<T>` can be safely created via [`NonNull::new`] and thus doesn't
283-
/// necessarily own the data pointed to nor is the data guaranteed to live
284-
/// as long as the pointer.
285-
///
286-
/// [`NonNull::new`]: ../../core/ptr/struct.NonNull.html#method.new
287-
///
288-
/// # Examples
289-
///
290-
/// ```
291-
/// fn main() {
292-
/// let x = Box::new(5);
293-
/// let ptr = Box::into_non_null_raw(x);
294-
/// let x = unsafe { Box::from_non_null_raw(ptr) };
295-
/// }
296-
/// ```
297-
#[stable(feature = "nonnull", since = "1.24.0")]
298-
#[inline]
299-
pub unsafe fn from_non_null_raw(u: NonNull<T>) -> Self {
300-
Box(u.into())
301-
}
302-
303275
/// Consumes the `Box`, returning the wrapped raw pointer.
304276
///
305277
/// After calling this function, the caller is responsible for the
@@ -331,19 +303,15 @@ impl<T: ?Sized> Box<T> {
331303
/// After calling this function, the caller is responsible for the
332304
/// memory previously managed by the `Box`. In particular, the
333305
/// caller should properly destroy `T` and release the memory. The
334-
/// proper way to do so is to either convert the `NonNull<T>` pointer:
335-
///
336-
/// - Into a `Box` with the [`Box::from_non_null_raw`] function.
337-
///
338-
/// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`]
339-
/// function.
306+
/// proper way to do so is to convert the `NonNull<T>` pointer
307+
/// into a raw pointer and back into a `Box` with the [`Box::from_raw`]
308+
/// function.
340309
///
341310
/// Note: this is an associated function, which means that you have
342311
/// to call it as `Box::into_non_null_raw(b)`
343312
/// instead of `b.into_non_null_raw()`. This
344313
/// is so that there is no conflict with a method on the inner type.
345314
///
346-
/// [`Box::from_non_null_raw`]: struct.Box.html#method.from_non_null_raw
347315
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
348316
///
349317
/// # Examples

0 commit comments

Comments
 (0)