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
This commit is contained in:
bors 2016-01-17 08:40:01 +00:00
commit 87608746f0
2 changed files with 6 additions and 1 deletions

View File

@ -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>() }
}

View File

@ -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) {