about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-02-17 05:17:19 -0500
committerNiko Matsakis <niko@alum.mit.edu>2015-03-17 08:34:25 -0400
commit5f5ed62298e5e366b931363b804631305178df5c (patch)
tree4c434eeafbd58ab1bc9a67b46865c3e45cdaeb49 /src/liballoc
parentbde09eea35113f25d4e0bcc4a8344de971f3069a (diff)
downloadrust-5f5ed62298e5e366b931363b804631305178df5c.tar.gz
rust-5f5ed62298e5e366b931363b804631305178df5c.zip
Remove subtyping for object types and replace with an *upcast* coercion.
This upcast coercion currently preserves the vtable for the object, but
eventually it can be used to create a derived vtable. The upcast
coercion is not introduced into method dispatch; see comment on #18737
for information about why. Fixes #18737.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 6d865d2bffa..808830d4648 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -241,7 +241,7 @@ pub trait BoxAny {
     /// Returns the boxed value if it is of type `T`, or
     /// `Err(Self)` if it isn't.
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn downcast<T: 'static>(self) -> Result<Box<T>, Self>;
+    fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>>;
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -264,6 +264,15 @@ impl BoxAny for Box<Any> {
     }
 }
 
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl BoxAny for Box<Any+Send> {
+    #[inline]
+    fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
+        <Box<Any>>::downcast(self)
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {