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