Debian Codegraph @

gcc/testsuite/rust/execute/torture/match2.rs

raw
1 // { dg-output "123\r*\n80\r*\n" }
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 }
5
6 enum Foo {
7 C(i32),
8 D { x: i32, y: i32 },
9 }
10
11 fn inspect(f: Foo) -> i32 {
12 match f {
13 Foo::C(x) => x,
14 Foo::D { x, y } => y,
15 }
16 }
17
18 fn main() -> i32 {
19 let a = Foo::C(123);
20 let b = Foo::D { x: 20, y: 80 };
21
22 let result = inspect(a);
23 unsafe {
24 let a = "%i\n\0";
25 let b = a as *const str;
26 let c = b as *const i8;
27
28 printf(c, result);
29 }
30
31 let result = inspect(b);
32 unsafe {
33 let a = "%i\n\0";
34 let b = a as *const str;
35 let c = b as *const i8;
36
37 printf(c, result);
38 }
39
40 0
41 }