]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/match-vec-unreachable.rs
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / pattern / usefulness / match-vec-unreachable.rs
1 #![deny(unreachable_patterns)]
2
3 fn main() {
4     let x: Vec<(isize, isize)> = Vec::new();
5     let x: &[(isize, isize)] = &x;
6     match *x {
7         [a, (2, 3), _] => (),
8         [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
9         _ => ()
10     }
11
12     let x: Vec<String> = vec!["foo".to_string(),
13                               "bar".to_string(),
14                               "baz".to_string()];
15     let x: &[String] = &x;
16     match *x {
17         [ref a, _, _, ..] => { println!("{}", a); }
18         [_, _, _, _, _] => { } //~ ERROR unreachable pattern
19         _ => { }
20     }
21
22     let x: Vec<char> = vec!['a', 'b', 'c'];
23     let x: &[char] = &x;
24     match *x {
25         ['a', 'b', 'c', ref _tail @ ..] => {}
26         ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
27         _ => {}
28     }
29 }