aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/exhaustiveness1.rs
blob: 356636b4e1fb793ab93f040ac83c0c588c1d6fe0 (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
46
47
48
49
50
51
struct S {
    a: i32,
}

fn s1(s: S) {
    match s {
        S { a: _ } => {}
    }
}

fn s2(s: S) {
    match s {
        _ => {}
    }
}

fn s3(s: S) {
    match s {}
}

enum E {
    A(),
    B(),
    C(),
}

fn e1(e: E) {
    match e {
        // { dg-error "non-exhaustive patterns: 'E::B..' not covered" "" { target *-*-* } .-1 }
        E::A() => {}
        E::C() => {}
    }
}

fn e2(e: E) {
    match e {
        // { dg-error "non-exhaustive patterns: 'E::A..' not covered" "" { target *-*-* } .-1 }
        E::B() => {}
        E::C() => {}
    }
}

fn e3(e: E) {
    match e {
        E::A() => {}
        E::B() => {}
        E::C() => {}
    }
}

fn main() {}