diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 26f8522e1c18a..000dda59e3dda 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -15,7 +15,6 @@ use core::clone::Clone; use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; use core::default::Default; use core::fmt; -use core::intrinsics; use core::kinds::Sized; use core::mem; use core::option::Option; @@ -104,17 +103,14 @@ pub trait BoxAny { } #[stable] -impl BoxAny for Box { +impl BoxAny for Box { #[inline] - fn downcast(self) -> Result, Box> { + fn downcast(self) -> Result, Box> { if self.is::() { unsafe { // Get the raw representation of the trait object let to: TraitObject = - *mem::transmute::<&Box, &TraitObject>(&self); - - // Prevent destructor on self being run - intrinsics::forget(self); + mem::transmute::, TraitObject>(self); // Extract the data pointer Ok(mem::transmute(to.data)) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 5511266b4cd22..ebd6fab34e9b5 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -71,7 +71,7 @@ #![stable] -use mem::{transmute, transmute_copy}; +use mem::{transmute}; use option::{Option, Some, None}; use raw::TraitObject; use intrinsics::TypeId; @@ -134,7 +134,7 @@ impl<'a> AnyRefExt<'a> for &'a Any { if self.is::() { unsafe { // Get the raw representation of the trait object - let to: TraitObject = transmute_copy(&self); + let to: TraitObject = transmute(self); // Extract the data pointer Some(transmute(to.data)) @@ -162,7 +162,7 @@ impl<'a> AnyMutRefExt<'a> for &'a mut Any { if self.is::() { unsafe { // Get the raw representation of the trait object - let to: TraitObject = transmute_copy(&self); + let to: TraitObject = transmute(self); // Extract the data pointer Some(transmute(to.data))