]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-fn-type-name.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / consts / const-fn-type-name.rs
CommitLineData
dc9dc135
XL
1// run-pass
2
3#![feature(core_intrinsics)]
dfeec247 4#![feature(const_type_name)]
dc9dc135
XL
5#![allow(dead_code)]
6
7const fn type_name_wrapper<T>(_: &T) -> &'static str {
416331ca 8 core::intrinsics::type_name::<T>()
dc9dc135
XL
9}
10
11struct Struct<TA, TB, TC> {
12 a: TA,
13 b: TB,
14 c: TC,
15}
16
17type StructInstantiation = Struct<i8, f64, bool>;
18
19const CONST_STRUCT: StructInstantiation = StructInstantiation {
20 a: 12,
21 b: 13.7,
22 c: false,
23};
24
25const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT);
26
27fn main() {
28 let non_const_struct = StructInstantiation {
29 a: 87,
30 b: 65.99,
31 c: true,
32 };
33
34 let non_const_struct_name = type_name_wrapper(&non_const_struct);
35
36 assert_eq!(CONST_STRUCT_NAME, non_const_struct_name);
37}