]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-fn-type-name-any.rs
Merge branch 'debian/sid' into debian/experimental
[rustc.git] / src / test / ui / consts / const-fn-type-name-any.rs
1 // run-pass
2
3 #![feature(const_type_name)]
4 #![allow(dead_code)]
5
6 const fn type_name_wrapper<T>(_: &T) -> &'static str {
7 std::any::type_name::<T>()
8 }
9
10 struct Struct<TA, TB, TC> {
11 a: TA,
12 b: TB,
13 c: TC,
14 }
15
16 type StructInstantiation = Struct<i8, f64, bool>;
17
18 const CONST_STRUCT: StructInstantiation = StructInstantiation { a: 12, b: 13.7, c: false };
19
20 const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT);
21
22 fn main() {
23 let non_const_struct = StructInstantiation { a: 87, b: 65.99, c: true };
24
25 let non_const_struct_name = type_name_wrapper(&non_const_struct);
26
27 assert_eq!(CONST_STRUCT_NAME, non_const_struct_name);
28 }