about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikolai Vazquez <nvazquez1297@gmail.com>2017-09-26 21:16:59 -0400
committerNikolai Vazquez <nvazquez1297@gmail.com>2017-09-26 21:16:59 -0400
commitedb2c2d291811f9b21ed8bd1499648a0614f6fc8 (patch)
treec5344458cddddb73bf31c7dc629442722b5546d1
parent1c4510adc81bd7623bc2993b42ee7d87320f1f2b (diff)
downloadrust-edb2c2d291811f9b21ed8bd1499648a0614f6fc8.tar.gz
rust-edb2c2d291811f9b21ed8bd1499648a0614f6fc8.zip
Remove uses of mem::transmute in Box methods
Makes use of conversions via Unique.
-rw-r--r--src/liballoc/boxed.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 4341b0b2975..512c7194fe3 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -269,7 +269,7 @@ impl<T: ?Sized> Box<T> {
     #[stable(feature = "box_raw", since = "1.4.0")]
     #[inline]
     pub unsafe fn from_raw(raw: *mut T) -> Self {
-        mem::transmute(raw)
+        Box(Unique::new_unchecked(raw))
     }
 
     /// Consumes the `Box`, returning the wrapped raw pointer.
@@ -295,7 +295,7 @@ impl<T: ?Sized> Box<T> {
     #[stable(feature = "box_raw", since = "1.4.0")]
     #[inline]
     pub fn into_raw(b: Box<T>) -> *mut T {
-        unsafe { mem::transmute(b) }
+        Box::into_unique(b).as_ptr()
     }
 
     /// Consumes the `Box`, returning the wrapped pointer as `Unique<T>`.
@@ -326,7 +326,9 @@ impl<T: ?Sized> Box<T> {
                issue = "27730")]
     #[inline]
     pub fn into_unique(b: Box<T>) -> Unique<T> {
-        unsafe { mem::transmute(b) }
+        let u = b.0;
+        mem::forget(b);
+        u
     }
 }