blob: 2ae3ca7db4ef8244a86c53e5316a7a61451c5f30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// { dg-output "x:15\r*\ny:20\r*\n" }
extern "C" {
fn printf(s: *const i8, ...);
}
enum Foo {
A,
B,
}
fn inspect(f: Foo, g: u8) -> i32 {
match (f, g) {
(Foo::A, 1) => {
return 5;
}
(Foo::A, 2) => {
return 10;
}
(Foo::B, 2) => {
return 15;
}
_ => {
return 20;
}
}
return 25;
}
fn main() -> i32 {
let x = inspect(Foo::B, 2);
let y = inspect(Foo::B, 1);
unsafe {
printf("x:%d\n" as *const str as *const i8, x);
}
unsafe {
printf("y:%d\n" as *const str as *const i8, y);
}
y - x - 5
}
|