about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-31 10:36:28 +0000
committerbors <bors@rust-lang.org>2017-12-31 10:36:28 +0000
commite03742368f266d4ca1626fa674c47ee2e165a00e (patch)
treea50de20e8bac8416e6f32fd18c4dc2e3d31746f4 /src/liballoc
parenta18dea908ca2a89cc1c7f4b0416924382ca145e6 (diff)
parent0fbcb7b873d140341fcfead9c47b1468617a596f (diff)
downloadrust-e03742368f266d4ca1626fa674c47ee2e165a00e.tar.gz
rust-e03742368f266d4ca1626fa674c47ee2e165a00e.zip
Auto merge of #47004 - nvzqz:rc-conversions, r=bluss,kennytm
Remove transmute in From<&str> impls for Arc/Rc

Performs conversion via raw pointer casts.
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) }
     }
 }