From f53ac185acbf85a781f3601695fb83359290f890 Mon Sep 17 00:00:00 2001 From: TankhouseAle <51239665+TankhouseAle@users.noreply.github.com> Date: Mon, 3 Jun 2019 14:36:22 -0400 Subject: [PATCH] Re-add test file --- src/test/run-pass/ctfe/const-fn-type-name.rs | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/run-pass/ctfe/const-fn-type-name.rs diff --git a/src/test/run-pass/ctfe/const-fn-type-name.rs b/src/test/run-pass/ctfe/const-fn-type-name.rs new file mode 100644 index 000000000000..2ee6415aa68b --- /dev/null +++ b/src/test/run-pass/ctfe/const-fn-type-name.rs @@ -0,0 +1,37 @@ +// run-pass + +#![feature(core_intrinsics)] +#![feature(const_fn)] +#![allow(dead_code)] + +const fn type_name_wrapper(_: &T) -> &'static str { + unsafe { core::intrinsics::type_name::() } +} + +struct Struct { + a: TA, + b: TB, + c: TC, +} + +type StructInstantiation = Struct; + +const CONST_STRUCT: StructInstantiation = StructInstantiation { + a: 12, + b: 13.7, + c: false, +}; + +const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT); + +fn main() { + let non_const_struct = StructInstantiation { + a: 87, + b: 65.99, + c: true, + }; + + let non_const_struct_name = type_name_wrapper(&non_const_struct); + + assert_eq!(CONST_STRUCT_NAME, non_const_struct_name); +}