rust/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs

106 lines
2.2 KiB
Rust
Raw Normal View History

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];
2019-11-16 10:18:46 -06:00
let s10: &[bool; 10] = &[false; 10];
match s2 {
//~^ ERROR `&[false, _]` not covered
[true, .., true] => {}
}
match s3 {
//~^ ERROR `&[false, ..]` not covered
2019-11-16 10:18:46 -06:00
[true, .., true] => {}
}
match s10 {
//~^ ERROR `&[false, ..]` not covered
2019-11-16 10:18:46 -06:00
[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] => {}
}
2019-10-05 16:57:52 -05:00
match s {
//~^ ERROR `&[_, _, .., true]` not covered
2019-10-05 16:57:52 -05:00
[] => {}
[_] => {}
[_, _] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[true, _, .., _]` not covered
2019-10-05 16:57:52 -05:00
[] => {}
[_] => {}
[_, _] => {}
[false, .., false] => {}
}
2019-11-17 16:25:51 -06:00
const CONST: &[bool] = &[true];
match s {
//~^ ERROR `&[..]` not covered
CONST => {}
}
match s {
//~^ ERROR `&[true]` not covered
[] => {},
[false] => {},
CONST => {},
[_, _, ..] => {}
}
const CONST1: &[bool; 1] = &[true];
match s1 {
//~^ ERROR `&[false]` not covered
2019-11-17 16:25:51 -06:00
CONST1 => {}
}
match s1 {
CONST1 => {}
[false] => {}
}
}