aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/match-slicepattern-array-1.rs
blob: 95c55d8f9d5e919208aba4f46794fd5b131c78af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// { dg-output "correct\r*" }
extern "C" {
    fn puts(s: *const i8);
}

fn main() -> i32 {
    let a = [0, 1];
    let mut ret = 1;

    match a {
        [0, 0] => {
            /* should not take this path */
            unsafe { puts("wrong\0" as *const str as *const i8) }
        },
        [0, b] => {
            ret -= b;
            unsafe { puts("correct\0" as *const str as *const i8) }
        },
        _ => {}
    }

    ret
}