diff options
| author | bors <bors@rust-lang.org> | 2015-01-19 23:35:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-19 23:35:12 +0000 |
| commit | 65b61ffb3f55c996eceded6c91281911b671d978 (patch) | |
| tree | d0ab6ddb6042d3fdaf3824372a8e2d6fc9def19a /src/test | |
| parent | 7f8c687fdfbf076ef1667f4d95633d4e0812b516 (diff) | |
| parent | 70f7165cc8975337964118af4d30f40b98f5edeb (diff) | |
| download | rust-65b61ffb3f55c996eceded6c91281911b671d978.tar.gz rust-65b61ffb3f55c996eceded6c91281911b671d978.zip | |
Auto merge of #21165 - alexcrichton:second-pass-type-id, r=aturon
This commit aims to stabilize the `TypeId` abstraction by moving it out of the `intrinsics` module into the `any` module of the standard library. Specifically, * `TypeId` is now defined at `std::any::TypeId` * `TypeId::hash` has been removed in favor of an implementation of `Hash`. This commit also performs a final pass over the `any` module, confirming the following: * `Any::get_type_id` remains unstable as *usage* of the `Any` trait will likely never require this, and the `Any` trait does not need to be implemented for any other types. As a result, this implementation detail can remain unstable until associated statics are implemented. * `Any::downcast_ref` is now stable * `Any::downcast_mut` is now stable * `BoxAny` remains unstable. While a direct impl on `Box<Any>` is allowed today it does not allow downcasting of trait objects like `Box<Any + Send>` (those returned from `Thread::join`). This is covered by #18737. * `BoxAny::downcast` is now stable.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/auxiliary/issue13507.rs | 2 | ||||
| -rw-r--r-- | src/test/auxiliary/typeid-intrinsic.rs | 21 | ||||
| -rw-r--r-- | src/test/auxiliary/typeid-intrinsic2.rs | 21 | ||||
| -rw-r--r-- | src/test/compile-fail/extern-with-type-bounds.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-18389.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/issue-13507-2.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/type-id-higher-rank.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/typeid-intrinsic.rs | 43 |
8 files changed, 46 insertions, 51 deletions
diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index c2820a8d4ae..f24721adb5d 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -9,7 +9,7 @@ // except according to those terms. pub mod testtypes { - use std::intrinsics::TypeId; + use std::any::TypeId; pub fn type_ids() -> Vec<TypeId> { let mut ids = vec!(); diff --git a/src/test/auxiliary/typeid-intrinsic.rs b/src/test/auxiliary/typeid-intrinsic.rs index b6c35f48010..82f613ee117 100644 --- a/src/test/auxiliary/typeid-intrinsic.rs +++ b/src/test/auxiliary/typeid-intrinsic.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::intrinsics; -use std::intrinsics::TypeId; +use std::any::TypeId; pub struct A; pub struct B(Option<A>); @@ -21,13 +20,13 @@ pub type F = Option<int>; pub type G = uint; pub type H = &'static str; -pub unsafe fn id_A() -> TypeId { intrinsics::type_id::<A>() } -pub unsafe fn id_B() -> TypeId { intrinsics::type_id::<B>() } -pub unsafe fn id_C() -> TypeId { intrinsics::type_id::<C>() } -pub unsafe fn id_D() -> TypeId { intrinsics::type_id::<D>() } -pub unsafe fn id_E() -> TypeId { intrinsics::type_id::<E>() } -pub unsafe fn id_F() -> TypeId { intrinsics::type_id::<F>() } -pub unsafe fn id_G() -> TypeId { intrinsics::type_id::<G>() } -pub unsafe fn id_H() -> TypeId { intrinsics::type_id::<H>() } +pub unsafe fn id_A() -> TypeId { TypeId::of::<A>() } +pub unsafe fn id_B() -> TypeId { TypeId::of::<B>() } +pub unsafe fn id_C() -> TypeId { TypeId::of::<C>() } +pub unsafe fn id_D() -> TypeId { TypeId::of::<D>() } +pub unsafe fn id_E() -> TypeId { TypeId::of::<E>() } +pub unsafe fn id_F() -> TypeId { TypeId::of::<F>() } +pub unsafe fn id_G() -> TypeId { TypeId::of::<G>() } +pub unsafe fn id_H() -> TypeId { TypeId::of::<H>() } -pub unsafe fn foo<T: 'static>() -> TypeId { intrinsics::type_id::<T>() } +pub unsafe fn foo<T: 'static>() -> TypeId { TypeId::of::<T>() } diff --git a/src/test/auxiliary/typeid-intrinsic2.rs b/src/test/auxiliary/typeid-intrinsic2.rs index b6c35f48010..82f613ee117 100644 --- a/src/test/auxiliary/typeid-intrinsic2.rs +++ b/src/test/auxiliary/typeid-intrinsic2.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::intrinsics; -use std::intrinsics::TypeId; +use std::any::TypeId; pub struct A; pub struct B(Option<A>); @@ -21,13 +20,13 @@ pub type F = Option<int>; pub type G = uint; pub type H = &'static str; -pub unsafe fn id_A() -> TypeId { intrinsics::type_id::<A>() } -pub unsafe fn id_B() -> TypeId { intrinsics::type_id::<B>() } -pub unsafe fn id_C() -> TypeId { intrinsics::type_id::<C>() } -pub unsafe fn id_D() -> TypeId { intrinsics::type_id::<D>() } -pub unsafe fn id_E() -> TypeId { intrinsics::type_id::<E>() } -pub unsafe fn id_F() -> TypeId { intrinsics::type_id::<F>() } -pub unsafe fn id_G() -> TypeId { intrinsics::type_id::<G>() } -pub unsafe fn id_H() -> TypeId { intrinsics::type_id::<H>() } +pub unsafe fn id_A() -> TypeId { TypeId::of::<A>() } +pub unsafe fn id_B() -> TypeId { TypeId::of::<B>() } +pub unsafe fn id_C() -> TypeId { TypeId::of::<C>() } +pub unsafe fn id_D() -> TypeId { TypeId::of::<D>() } +pub unsafe fn id_E() -> TypeId { TypeId::of::<E>() } +pub unsafe fn id_F() -> TypeId { TypeId::of::<F>() } +pub unsafe fn id_G() -> TypeId { TypeId::of::<G>() } +pub unsafe fn id_H() -> TypeId { TypeId::of::<H>() } -pub unsafe fn foo<T: 'static>() -> TypeId { intrinsics::type_id::<T>() } +pub unsafe fn foo<T: 'static>() -> TypeId { TypeId::of::<T>() } diff --git a/src/test/compile-fail/extern-with-type-bounds.rs b/src/test/compile-fail/extern-with-type-bounds.rs index d2c88865d54..ade8b397e00 100644 --- a/src/test/compile-fail/extern-with-type-bounds.rs +++ b/src/test/compile-fail/extern-with-type-bounds.rs @@ -10,11 +10,9 @@ #![feature(intrinsics)] -use std::intrinsics::TypeId; - extern "rust-intrinsic" { // Real example from libcore - fn type_id<T: ?Sized + 'static>() -> TypeId; + fn type_id<T: ?Sized + 'static>() -> u64; // Silent bounds made explicit to make sure they are actually // resolved. diff --git a/src/test/compile-fail/issue-18389.rs b/src/test/compile-fail/issue-18389.rs index 37bb1cb1911..20323e99003 100644 --- a/src/test/compile-fail/issue-18389.rs +++ b/src/test/compile-fail/issue-18389.rs @@ -11,7 +11,7 @@ #![feature(unboxed_closures)] use std::any::Any; -use std::intrinsics::TypeId; +use std::any::TypeId; pub trait Pt {} pub trait Rt {} diff --git a/src/test/run-pass/issue-13507-2.rs b/src/test/run-pass/issue-13507-2.rs index 4d150e7a68e..1c0283070a2 100644 --- a/src/test/run-pass/issue-13507-2.rs +++ b/src/test/run-pass/issue-13507-2.rs @@ -12,7 +12,7 @@ extern crate issue13507; use issue13507::testtypes; -use std::intrinsics::TypeId; +use std::any::TypeId; pub fn type_ids() -> Vec<TypeId> { let mut ids = vec!(); diff --git a/src/test/run-pass/type-id-higher-rank.rs b/src/test/run-pass/type-id-higher-rank.rs index 7287d149f51..b114391a36d 100644 --- a/src/test/run-pass/type-id-higher-rank.rs +++ b/src/test/run-pass/type-id-higher-rank.rs @@ -13,7 +13,7 @@ #![feature(unboxed_closures)] -use std::intrinsics::TypeId; +use std::any::TypeId; fn main() { // Bare fns diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index e346c4ff349..a251fcc7327 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -15,41 +15,40 @@ extern crate "typeid-intrinsic" as other1; extern crate "typeid-intrinsic2" as other2; use std::hash::{self, SipHasher}; -use std::intrinsics; -use std::intrinsics::TypeId; +use std::any::TypeId; struct A; struct Test; pub fn main() { unsafe { - assert_eq!(intrinsics::type_id::<other1::A>(), other1::id_A()); - assert_eq!(intrinsics::type_id::<other1::B>(), other1::id_B()); - assert_eq!(intrinsics::type_id::<other1::C>(), other1::id_C()); - assert_eq!(intrinsics::type_id::<other1::D>(), other1::id_D()); - assert_eq!(intrinsics::type_id::<other1::E>(), other1::id_E()); - assert_eq!(intrinsics::type_id::<other1::F>(), other1::id_F()); - assert_eq!(intrinsics::type_id::<other1::G>(), other1::id_G()); - assert_eq!(intrinsics::type_id::<other1::H>(), other1::id_H()); + assert_eq!(TypeId::of::<other1::A>(), other1::id_A()); + assert_eq!(TypeId::of::<other1::B>(), other1::id_B()); + assert_eq!(TypeId::of::<other1::C>(), other1::id_C()); + assert_eq!(TypeId::of::<other1::D>(), other1::id_D()); + assert_eq!(TypeId::of::<other1::E>(), other1::id_E()); + assert_eq!(TypeId::of::<other1::F>(), other1::id_F()); + assert_eq!(TypeId::of::<other1::G>(), other1::id_G()); + assert_eq!(TypeId::of::<other1::H>(), other1::id_H()); - assert_eq!(intrinsics::type_id::<other2::A>(), other2::id_A()); - assert_eq!(intrinsics::type_id::<other2::B>(), other2::id_B()); - assert_eq!(intrinsics::type_id::<other2::C>(), other2::id_C()); - assert_eq!(intrinsics::type_id::<other2::D>(), other2::id_D()); - assert_eq!(intrinsics::type_id::<other2::E>(), other2::id_E()); - assert_eq!(intrinsics::type_id::<other2::F>(), other2::id_F()); - assert_eq!(intrinsics::type_id::<other2::G>(), other2::id_G()); - assert_eq!(intrinsics::type_id::<other2::H>(), other2::id_H()); + assert_eq!(TypeId::of::<other2::A>(), other2::id_A()); + assert_eq!(TypeId::of::<other2::B>(), other2::id_B()); + assert_eq!(TypeId::of::<other2::C>(), other2::id_C()); + assert_eq!(TypeId::of::<other2::D>(), other2::id_D()); + assert_eq!(TypeId::of::<other2::E>(), other2::id_E()); + assert_eq!(TypeId::of::<other2::F>(), other2::id_F()); + assert_eq!(TypeId::of::<other2::G>(), other2::id_G()); + assert_eq!(TypeId::of::<other2::H>(), other2::id_H()); assert_eq!(other1::id_F(), other2::id_F()); assert_eq!(other1::id_G(), other2::id_G()); assert_eq!(other1::id_H(), other2::id_H()); - assert_eq!(intrinsics::type_id::<int>(), other2::foo::<int>()); - assert_eq!(intrinsics::type_id::<int>(), other1::foo::<int>()); + assert_eq!(TypeId::of::<int>(), other2::foo::<int>()); + assert_eq!(TypeId::of::<int>(), other1::foo::<int>()); assert_eq!(other2::foo::<int>(), other1::foo::<int>()); - assert_eq!(intrinsics::type_id::<A>(), other2::foo::<A>()); - assert_eq!(intrinsics::type_id::<A>(), other1::foo::<A>()); + assert_eq!(TypeId::of::<A>(), other2::foo::<A>()); + assert_eq!(TypeId::of::<A>(), other1::foo::<A>()); assert_eq!(other2::foo::<A>(), other1::foo::<A>()); } |
