Skip to content

Commit 5657b28

Browse files
Centri3NCGThompson
authored andcommitted
Add back test
1 parent b8b92cb commit 5657b28

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// compile-flags: --crate-type=lib
2+
#![feature(core_intrinsics)]
3+
4+
use std::intrinsics::is_compile_time_known;
5+
6+
pub struct A(u32);
7+
pub enum B {
8+
Ye(u32),
9+
}
10+
11+
#[inline]
12+
pub fn tuple_struct(a: A) -> i32 {
13+
if unsafe { is_compile_time_known(a) } { 1 } else { 0 }
14+
}
15+
16+
// CHECK-LABEL: @tuple_struct_true(
17+
#[no_mangle]
18+
pub fn tuple_struct_true() -> i32 {
19+
// CHECK: ret i32 1
20+
tuple_struct(A(1))
21+
}
22+
23+
// CHECK-LABEL: @tuple_struct_false(
24+
#[no_mangle]
25+
pub fn tuple_struct_false(a: A) -> i32 {
26+
// CHECK: ret i32 0
27+
tuple_struct(a)
28+
}
29+
30+
#[inline]
31+
pub fn r#enum(b: B) -> i32 {
32+
if unsafe { is_compile_time_known(b) } { 3 } else { 2 }
33+
}
34+
35+
// CHECK-LABEL: @enum_true(
36+
#[no_mangle]
37+
pub fn enum_true() -> i32 {
38+
// CHECK: ret i32 3
39+
r#enum(B::Ye(2))
40+
}
41+
42+
// CHECK-LABEL: @enum_false(
43+
#[no_mangle]
44+
pub fn enum_false(b: B) -> i32 {
45+
// CHECK: ret i32 2
46+
r#enum(b)
47+
}

0 commit comments

Comments
 (0)