summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
blob: 46e0da5be9b4fdf126f3c7041fb16c28b6245568 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
fn main() {
    let s: &[bool] = &[true; 0];
    let s1: &[bool; 1] = &[false; 1];
    let s2: &[bool; 2] = &[false; 2];
    let s3: &[bool; 3] = &[false; 3];
    let s10: &[bool; 10] = &[false; 10];

    match s2 {
        //~^ ERROR `&[false, _]` not covered
        [true, .., true] => {}
    }
    match s3 {
        //~^ ERROR `&[false, ..]` not covered
        [true, .., true] => {}
    }
    match s10 {
        //~^ ERROR `&[false, ..]` not covered
        [true, .., true] => {}
    }

    match s1 {
        [true, ..] => {}
        [.., false] => {}
    }
    match s2 {
        //~^ ERROR `&[false, true]` not covered
        [true, ..] => {}
        [.., false] => {}
    }
    match s3 {
        //~^ ERROR `&[false, .., true]` not covered
        [true, ..] => {}
        [.., false] => {}
    }
    match s {
        //~^ ERROR `&[false, .., true]` not covered
        [] => {}
        [true, ..] => {}
        [.., false] => {}
    }

    match s {
        //~^ ERROR `&[_, ..]` not covered
        [] => {}
    }
    match s {
        //~^ ERROR `&[_, _, ..]` not covered
        [] => {}
        [_] => {}
    }
    match s {
        //~^ ERROR `&[false, ..]` not covered
        [] => {}
        [true, ..] => {}
    }
    match s {
        //~^ ERROR `&[false, _, ..]` not covered
        [] => {}
        [_] => {}
        [true, ..] => {}
    }
    match s {
        //~^ ERROR `&[_, .., false]` not covered
        [] => {}
        [_] => {}
        [.., true] => {}
    }

    match s {
        //~^ ERROR `&[_, _, .., true]` not covered
        [] => {}
        [_] => {}
        [_, _] => {}
        [.., false] => {}
    }
    match s {
        //~^ ERROR `&[true, _, .., _]` not covered
        [] => {}
        [_] => {}
        [_, _] => {}
        [false, .., false] => {}
    }

    const CONST: &[bool] = &[true];
    match s {
        //~^ ERROR `&[]` and `&[_, _, ..]` not covered
        &[true] => {}
    }
    match s {
        //~^ ERROR `&[]` and `&[_, _, ..]` not covered
        CONST => {}
    }
    match s {
        //~^ ERROR `&[]` and `&[_, _, ..]` not covered
        CONST => {}
        &[false] => {}
    }
    match s {
        //~^ ERROR `&[]` and `&[_, _, ..]` not covered
        &[false] => {}
        CONST => {}
    }
    match s {
        //~^ ERROR `&[_, _, ..]` not covered
        &[] => {}
        CONST => {}
    }
    match s {
        //~^ ERROR `&[false]` not covered
        &[] => {}
        CONST => {}
        &[_, _, ..] => {}
    }
    match s {
        [] => {}
        [false] => {}
        CONST => {}
        [_, _, ..] => {}
    }
    const CONST1: &[bool; 1] = &[true];
    match s1 {
        //~^ ERROR `&[false]` not covered
        CONST1 => {}
    }
    match s1 {
        CONST1 => {}
        [false] => {}
    }
}