2015-03-26 18:34:27 -07:00
|
|
|
#![feature(slice_patterns)]
|
2016-11-29 15:10:26 +08:00
|
|
|
#![deny(unreachable_patterns)]
|
2014-03-05 15:28:08 -08:00
|
|
|
|
2012-12-08 20:22:43 +00:00
|
|
|
fn main() {
|
2015-01-08 21:54:35 +11:00
|
|
|
let x: Vec<(isize, isize)> = Vec::new();
|
2015-02-01 21:53:25 -05:00
|
|
|
let x: &[(isize, isize)] = &x;
|
2016-03-11 12:54:59 +02:00
|
|
|
match *x {
|
2016-12-29 12:17:40 +08:00
|
|
|
[a, (2, 3), _] => (),
|
|
|
|
[(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
|
2012-12-08 20:22:43 +00:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
|
2014-05-25 03:17:19 -07:00
|
|
|
let x: Vec<String> = vec!["foo".to_string(),
|
|
|
|
"bar".to_string(),
|
|
|
|
"baz".to_string()];
|
2015-02-01 21:53:25 -05:00
|
|
|
let x: &[String] = &x;
|
2016-03-11 12:54:59 +02:00
|
|
|
match *x {
|
2016-11-29 15:10:26 +08:00
|
|
|
[ref a, _, _, ..] => { println!("{}", a); }
|
2014-03-07 16:15:50 -05:00
|
|
|
[_, _, _, _, _] => { } //~ ERROR unreachable pattern
|
2012-12-08 20:22:43 +00:00
|
|
|
_ => { }
|
|
|
|
}
|
|
|
|
|
2016-10-29 22:54:04 +01:00
|
|
|
let x: Vec<char> = vec!['a', 'b', 'c'];
|
2015-02-01 21:53:25 -05:00
|
|
|
let x: &[char] = &x;
|
2016-03-11 12:54:59 +02:00
|
|
|
match *x {
|
|
|
|
['a', 'b', 'c', ref _tail..] => {}
|
2012-12-08 20:22:43 +00:00
|
|
|
['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|