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 { #[inline] fn from(v: &str) -> Arc { - unsafe { mem::transmute(>::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 { #[inline] fn from(v: &str) -> Rc { - unsafe { mem::transmute(>::from(v.as_bytes())) } + let rc = Rc::<[u8]>::from(v.as_bytes()); + unsafe { Rc::from_raw(Rc::into_raw(rc) as *const str) } } }