Skip to content

Commit d0cc41d

Browse files
authored
Do an actual check with assert_eq, as suggested.
Also, use core::intrinsics::type_name instead of std::intrinsics::type_name, which I don't think makes any real difference but seems like it's probably more logical.
1 parent 67b3fde commit d0cc41d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/test/run-pass/ctfe/const-fn-type-name.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(dead_code)]
66

77
const fn type_name_wrapper<T>(_: &T) -> &'static str {
8-
unsafe { std::intrinsics::type_name::<T>() }
8+
unsafe { core::intrinsics::type_name::<T>() }
99
}
1010

1111
struct Struct<TA, TB, TC> {
@@ -25,14 +25,13 @@ const CONST_STRUCT: StructInstantiation = StructInstantiation {
2525
const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT);
2626

2727
fn main() {
28-
println!("{}", CONST_STRUCT_NAME);
29-
3028
let non_const_struct = StructInstantiation {
3129
a: 87,
3230
b: 65.99,
3331
c: true,
3432
};
33+
3534
let non_const_struct_name = type_name_wrapper(&non_const_struct);
3635

37-
println!("{}", non_const_struct_name);
36+
assert_eq!(CONST_STRUCT_NAME, non_const_struct_name);
3837
}

0 commit comments

Comments
 (0)