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