about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-01-17 08:40:01 +0000
committerbors <bors@rust-lang.org>2016-01-17 08:40:01 +0000
commit87608746f0c70b733f76eb5e8ff1d3346db63d3e (patch)
treee7c8dfc7b376b5848d7deed89fdad560f0e9c797
parent88463364bfb675fdecd2bf9b70c589cc5e7cb2fb (diff)
parent5d2275d53ec1f66527db9d903ed84a258927e0ba (diff)
downloadrust-87608746f0c70b733f76eb5e8ff1d3346db63d3e.tar.gz
rust-87608746f0c70b733f76eb5e8ff1d3346db63d3e.zip
Auto merge of #30928 - sfackler:any-unsized, r=aturon
This is a bit weird since unsized types can't be used in trait objects,
but Any is *also* used as pure marker trait since Reflect isn't stable.
There are many cases (e.g. TypeMap) where all you need is a TypeId.

r? @aturon
-rw-r--r--src/libcore/any.rs2
-rw-r--r--src/libcoretest/any.rs5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs
index 2ad121b03fa..cb9bf935cdb 100644
--- a/src/libcore/any.rs
+++ b/src/libcore/any.rs
@@ -99,7 +99,7 @@ pub trait Any: Reflect + 'static {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Reflect + 'static> Any for T {
+impl<T: Reflect + 'static + ?Sized > Any for T {
     fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
 }
 
diff --git a/src/libcoretest/any.rs b/src/libcoretest/any.rs
index eeaaa3e217e..a9fc8913182 100644
--- a/src/libcoretest/any.rs
+++ b/src/libcoretest/any.rs
@@ -119,6 +119,11 @@ fn any_fixed_vec() {
     assert!(!test.is::<[usize; 10]>());
 }
 
+#[test]
+fn any_unsized() {
+    fn is_any<T: Any + ?Sized>() {}
+    is_any::<[i32]>();
+}
 
 #[bench]
 fn bench_downcast_ref(b: &mut Bencher) {