4 // aux-build:typeid-intrinsic-aux1.rs
5 // aux-build:typeid-intrinsic-aux2.rs
7 #![feature(core_intrinsics)]
9 extern crate typeid_intrinsic_aux1 as other1;
10 extern crate typeid_intrinsic_aux2 as other2;
12 use std::hash::{SipHasher, Hasher, Hash};
19 assert_eq!(TypeId::of::<other1::A>(), other1::id_A());
20 assert_eq!(TypeId::of::<other1::B>(), other1::id_B());
21 assert_eq!(TypeId::of::<other1::C>(), other1::id_C());
22 assert_eq!(TypeId::of::<other1::D>(), other1::id_D());
23 assert_eq!(TypeId::of::<other1::E>(), other1::id_E());
24 assert_eq!(TypeId::of::<other1::F>(), other1::id_F());
25 assert_eq!(TypeId::of::<other1::G>(), other1::id_G());
26 assert_eq!(TypeId::of::<other1::H>(), other1::id_H());
27 assert_eq!(TypeId::of::<other1::I>(), other1::id_I());
29 assert_eq!(TypeId::of::<other2::A>(), other2::id_A());
30 assert_eq!(TypeId::of::<other2::B>(), other2::id_B());
31 assert_eq!(TypeId::of::<other2::C>(), other2::id_C());
32 assert_eq!(TypeId::of::<other2::D>(), other2::id_D());
33 assert_eq!(TypeId::of::<other2::E>(), other2::id_E());
34 assert_eq!(TypeId::of::<other2::F>(), other2::id_F());
35 assert_eq!(TypeId::of::<other2::G>(), other2::id_G());
36 assert_eq!(TypeId::of::<other2::H>(), other2::id_H());
37 assert_eq!(TypeId::of::<other1::I>(), other2::id_I());
39 assert_eq!(other1::id_F(), other2::id_F());
40 assert_eq!(other1::id_G(), other2::id_G());
41 assert_eq!(other1::id_H(), other2::id_H());
42 assert_eq!(other1::id_I(), other2::id_I());
44 assert_eq!(TypeId::of::<isize>(), other2::foo::<isize>());
45 assert_eq!(TypeId::of::<isize>(), other1::foo::<isize>());
46 assert_eq!(other2::foo::<isize>(), other1::foo::<isize>());
47 assert_eq!(TypeId::of::<A>(), other2::foo::<A>());
48 assert_eq!(TypeId::of::<A>(), other1::foo::<A>());
49 assert_eq!(other2::foo::<A>(), other1::foo::<A>());
51 // sanity test of TypeId
52 let (a, b, c) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(),
53 TypeId::of::<Test>());
54 let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(),
55 TypeId::of::<Test>());
65 // check it has a hash
66 let (a, b) = (TypeId::of::<usize>(), TypeId::of::<usize>());
68 let mut s1 = SipHasher::new();
70 let mut s2 = SipHasher::new();
73 assert_eq!(s1.finish(), s2.finish());
77 assert_eq!(TypeId::of::<other1::I32Iterator>(), other1::id_i32_iterator());
78 assert_eq!(TypeId::of::<other1::U32Iterator>(), other1::id_u32_iterator());
79 assert_eq!(other1::id_i32_iterator(), other2::id_i32_iterator());
80 assert_eq!(other1::id_u32_iterator(), other2::id_u32_iterator());
81 assert_ne!(other1::id_i32_iterator(), other1::id_u32_iterator());
82 assert_ne!(TypeId::of::<other1::I32Iterator>(), TypeId::of::<other1::U32Iterator>());
84 // Check fn pointer against collisions
86 TypeId::of::<fn(fn(A) -> A) -> A>(),
87 TypeId::of::<fn(fn() -> A, A) -> A>()
90 TypeId::of::<for<'a> fn(&'a i32) -> &'a i32>(),
91 TypeId::of::<for<'a> fn(&'a i32) -> &'static i32>()
94 TypeId::of::<for<'a, 'b> fn(&'a i32, &'b i32) -> &'a i32>(),
95 TypeId::of::<for<'a, 'b> fn(&'b i32, &'a i32) -> &'a i32>()