Debian Codegraph @

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

raw
1 // { dg-output "182 is more than 100\r*\n55 is less than 100\r*\n" }
2
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 fn foo(x: bool) -> i32 {
8 match x {
9 true => {
10 return 182;
11 }
12 false => {
13 return 55;
14 }
15 }
16 }
17
18 fn bar(y: i32) {
19 match y < 100 {
20 true => {
21 let a = "%i is less than 100\n\0";
22 let b = a as *const str;
23 let c = b as *const i8;
24
25 unsafe {
26 printf(c, y);
27 }
28 }
29 _ => {
30 let a = "%i is more than 100\n\0";
31 let b = a as *const str;
32 let c = b as *const i8;
33
34 unsafe {
35 printf(c, y);
36 }
37 }
38 }
39 }
40
41 fn main() -> i32 {
42 let a = foo(true);
43 let b = foo(false);
44
45 bar(a);
46 bar(b);
47
48 0
49 }