]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-fn-type-name.rs
Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkor
[rust.git] / src / test / ui / consts / const-fn-type-name.rs
1 // run-pass
2
3 #![feature(core_intrinsics)]
4 #![feature(const_fn)]
5 #![feature(const_type_name)]
6 #![allow(dead_code)]
7
8 const fn type_name_wrapper<T>(_: &T) -> &'static str {
9     core::intrinsics::type_name::<T>()
10 }
11
12 struct Struct<TA, TB, TC> {
13     a: TA,
14     b: TB,
15     c: TC,
16 }
17
18 type StructInstantiation = Struct<i8, f64, bool>;
19
20 const CONST_STRUCT: StructInstantiation = StructInstantiation {
21     a: 12,
22     b: 13.7,
23     c: false,
24 };
25
26 const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT);
27
28 fn main() {
29     let non_const_struct = StructInstantiation {
30         a: 87,
31         b: 65.99,
32         c: true,
33     };
34
35     let non_const_struct_name = type_name_wrapper(&non_const_struct);
36
37     assert_eq!(CONST_STRUCT_NAME, non_const_struct_name);
38 }