From 1b17eefa4aff87ae393c6d5aff7e90ff7c3c3185 Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Sat, 22 Nov 2014 16:06:21 -0800 Subject: Any: use plain transmute instead of transmute_copy for downcasting. transmute_copy is no longer needed and is just slow. --- src/liballoc/boxed.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 26f8522e1c1..000dda59e3d 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)) -- cgit 1.4.1-3-g733a5