about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-25 23:02:52 +0000
committerbors <bors@rust-lang.org>2015-05-25 23:02:52 +0000
commit7cb9914fceaeaa6a39add43d3da15bb6e1d191f6 (patch)
treefc885d585246974c4c95ff010b383b330fbba108 /src/liballoc
parentcc156c2f3819e8818c66e5f5d0bb143739e3bbb0 (diff)
parentd416fc1d40e39661153b2183726f7e71f51d24e3 (diff)
downloadrust-7cb9914fceaeaa6a39add43d3da15bb6e1d191f6.tar.gz
rust-7cb9914fceaeaa6a39add43d3da15bb6e1d191f6.zip
Auto merge of #25767 - mystor:patch-1, r=Gankro
By the same logic that `mem::forget` is safe, `boxed::into_raw` is actually a safe function.

Fixes #25755.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 35732dacd44..6633e48a814 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -139,24 +139,20 @@ impl<T : ?Sized> Box<T> {
 /// convert pointer back to `Box` with `Box::from_raw` function, because
 /// `Box` does not specify, how memory is allocated.
 ///
-/// Function is unsafe, because result of this function is no longer
-/// automatically managed that may lead to memory or other resource
-/// leak.
-///
 /// # Examples
 /// ```
 /// # #![feature(alloc)]
 /// use std::boxed;
 ///
 /// let seventeen = Box::new(17u32);
-/// let raw = unsafe { boxed::into_raw(seventeen) };
+/// let raw = boxed::into_raw(seventeen);
 /// let boxed_again = unsafe { Box::from_raw(raw) };
 /// ```
 #[unstable(feature = "alloc",
            reason = "may be renamed")]
 #[inline]
-pub unsafe fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {
-    mem::transmute(b)
+pub fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {
+    unsafe { mem::transmute(b) }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]