rust/tests/ui/pattern/usefulness/slice-patterns-reachability.rs

26 lines
626 B
Rust
Raw Normal View History

#![deny(unreachable_patterns)]
fn main() {
2019-11-17 16:25:51 -06:00
let s: &[bool] = &[];
match s {
[true, ..] => {}
[true, ..] => {} //~ ERROR unreachable pattern
[true] => {} //~ ERROR unreachable pattern
[..] => {}
}
match s {
[.., true] => {}
[.., true] => {} //~ ERROR unreachable pattern
[true] => {} //~ ERROR unreachable pattern
[..] => {}
}
match s {
[false, .., true] => {}
[false, .., true] => {} //~ ERROR unreachable pattern
[false, true] => {} //~ ERROR unreachable pattern
[false] => {}
[..] => {}
}
}