about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2016-08-25 20:56:47 -0400
committerAndrew Paseltiner <apaseltiner@gmail.com>2016-08-26 06:37:36 -0400
commit2b10df7f24828b09759277cc3a9c18c493c38ce0 (patch)
tree8a10bb092c5adea8b94ecbf5c4c415adb008fecf /src/liballoc
parenteaf71f8d1034f16140791f566cab3f3c9a0bf96a (diff)
downloadrust-2b10df7f24828b09759277cc3a9c18c493c38ce0.tar.gz
rust-2b10df7f24828b09759277cc3a9c18c493c38ce0.zip
Replace unnecessary uses of `TraitObject` with casts
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs9
-rw-r--r--src/liballoc/lib.rs2
2 files changed, 3 insertions, 8 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index dae12f6e8bd..c8a78f84f18 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -67,7 +67,6 @@ use core::mem;
 use core::ops::{CoerceUnsized, Deref, DerefMut};
 use core::ops::{BoxPlace, Boxed, InPlace, Place, Placer};
 use core::ptr::{self, Unique};
-use core::raw::TraitObject;
 use core::convert::From;
 
 /// A value that represents the heap. This is the default place that the `box`
@@ -428,12 +427,8 @@ impl Box<Any> {
     pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
         if self.is::<T>() {
             unsafe {
-                // Get the raw representation of the trait object
-                let raw = Box::into_raw(self);
-                let to: TraitObject = mem::transmute::<*mut Any, TraitObject>(raw);
-
-                // Extract the data pointer
-                Ok(Box::from_raw(to.data as *mut T))
+                let raw: *mut Any = Box::into_raw(self);
+                Ok(Box::from_raw(raw as *mut T))
             }
         } else {
             Err(self)
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index d9fd2d92710..c6453da3f46 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -91,7 +91,7 @@
 #![cfg_attr(stage0, feature(unsafe_no_drop_flag))]
 #![feature(unsize)]
 
-#![cfg_attr(not(test), feature(fused, raw, fn_traits, placement_new_protocol))]
+#![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol))]
 #![cfg_attr(test, feature(test, box_heap))]
 
 // Allow testing this library