]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-typeid-of-rpass.rs
Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup
[rust.git] / src / test / ui / consts / const-typeid-of-rpass.rs
1 // run-pass
2 #![feature(const_type_id)]
3 #![feature(core_intrinsics)]
4
5 use std::any::TypeId;
6
7 struct A;
8
9 static ID_ISIZE: TypeId = TypeId::of::<isize>();
10
11 pub fn main() {
12     assert_eq!(ID_ISIZE, TypeId::of::<isize>());
13
14     // sanity test of TypeId
15     const T: (TypeId, TypeId, TypeId) = (TypeId::of::<usize>(),
16                      TypeId::of::<&'static str>(),
17                      TypeId::of::<A>());
18     let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(),
19                      TypeId::of::<A>());
20
21     assert!(T.0 != T.1);
22     assert!(T.0 != T.2);
23     assert!(T.1 != T.2);
24
25     assert_eq!(T.0, d);
26     assert_eq!(T.1, e);
27     assert_eq!(T.2, f);
28
29     // Check fn pointer against collisions
30     const F: (TypeId, TypeId) = (TypeId::of::<fn(fn(A) -> A) -> A>(),
31             TypeId::of::<fn(fn() -> A, A) -> A>());
32
33     assert!(F.0 != F.1);
34 }