about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorNikolai Vazquez <nvazquez1297@gmail.com>2017-12-25 17:04:45 -0500
committerNikolai Vazquez <nvazquez1297@gmail.com>2017-12-25 17:04:45 -0500
commit0fbcb7b873d140341fcfead9c47b1468617a596f (patch)
treebe5a4395675d7a5bd7eb67f7e8b153fb28851def /src/liballoc
parent4a7c072fa61b42f96d8b75c37fc1edfd71172695 (diff)
downloadrust-0fbcb7b873d140341fcfead9c47b1468617a596f.tar.gz
rust-0fbcb7b873d140341fcfead9c47b1468617a596f.zip
Remove transmute in From<&str> impls for Arc/Rc
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs3
-rw-r--r--src/liballoc/rc.rs3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index 844b7083593..185af8835d1 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -1377,7 +1377,8 @@ impl<'a, T: Clone> From<&'a [T]> for Arc<[T]> {
 impl<'a> From<&'a str> for Arc<str> {
     #[inline]
     fn from(v: &str) -> Arc<str> {
-        unsafe { mem::transmute(<Arc<[u8]>>::from(v.as_bytes())) }
+        let arc = Arc::<[u8]>::from(v.as_bytes());
+        unsafe { Arc::from_raw(Arc::into_raw(arc) as *const str) }
     }
 }
 
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 358b5934b92..59079f9ba76 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -1099,7 +1099,8 @@ impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> {
 impl<'a> From<&'a str> for Rc<str> {
     #[inline]
     fn from(v: &str) -> Rc<str> {
-        unsafe { mem::transmute(<Rc<[u8]>>::from(v.as_bytes())) }
+        let rc = Rc::<[u8]>::from(v.as_bytes());
+        unsafe { Rc::from_raw(Rc::into_raw(rc) as *const str) }
     }
 }