Debian Codegraph @

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

raw
1 // { dg-output "zero to END_RANGE\r*\nzero to END_RANGE\r*\nelse\r*\n" }
2
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 const END_RANGE: i32 = 15;
8
9 fn foo(x: i32) {
10 match x {
11 0..=END_RANGE => {
12 let a = "zero to END_RANGE\n\0";
13 let b = a as *const str;
14 let c = b as *const i8;
15 unsafe {
16 printf(c);
17 }
18 }
19
20 _ => {
21 let a = "else\n\0";
22 let b = a as *const str;
23 let c = b as *const i8;
24 unsafe {
25 printf(c);
26 }
27 }
28 }
29 }
30
31 fn main() -> i32 {
32 foo(11);
33 foo(15);
34 foo(21);
35
36 0
37 }