From 5f5ed62298e5e366b931363b804631305178df5c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 17 Feb 2015 05:17:19 -0500 Subject: 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. --- src/liballoc/boxed.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/liballoc') 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(self) -> Result, Self>; + fn downcast(self) -> Result, Box>; } #[stable(feature = "rust1", since = "1.0.0")] @@ -264,6 +264,15 @@ impl BoxAny for Box { } } +#[cfg(not(stage0))] +#[stable(feature = "rust1", since = "1.0.0")] +impl BoxAny for Box { + #[inline] + fn downcast(self) -> Result, Box> { + >::downcast(self) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- cgit 1.4.1-3-g733a5