Debian Codegraph @

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

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