]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-typeid-of-rpass.rs
New upstream version 1.47.0~beta.2+dfsg1
[rustc.git] / src / test / ui / consts / const-typeid-of-rpass.rs
CommitLineData
b7449926 1// run-pass
2c00a5a8 2#![feature(core_intrinsics)]
2c00a5a8
XL
3
4use std::any::TypeId;
5
6struct A;
7
8static ID_ISIZE: TypeId = TypeId::of::<isize>();
9
10pub fn main() {
11 assert_eq!(ID_ISIZE, TypeId::of::<isize>());
12
13 // sanity test of TypeId
14 const T: (TypeId, TypeId, TypeId) = (TypeId::of::<usize>(),
15 TypeId::of::<&'static str>(),
16 TypeId::of::<A>());
17 let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(),
18 TypeId::of::<A>());
19
20 assert!(T.0 != T.1);
21 assert!(T.0 != T.2);
22 assert!(T.1 != T.2);
23
24 assert_eq!(T.0, d);
25 assert_eq!(T.1, e);
26 assert_eq!(T.2, f);
27
28 // Check fn pointer against collisions
29 const F: (TypeId, TypeId) = (TypeId::of::<fn(fn(A) -> A) -> A>(),
30 TypeId::of::<fn(fn() -> A, A) -> A>());
31
32 assert!(F.0 != F.1);
33}