]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/match-vec-unreachable.rs
New upstream version 1.16.0+dfsg1
[rustc.git] / src / test / compile-fail / match-vec-unreachable.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
c34b1796 11#![feature(slice_patterns)]
32a655c1
SL
12#![deny(unreachable_patterns)]
13#![allow(unused_variables)]
1a4d82fc 14
223e47cc 15fn main() {
1a4d82fc 16 let x: Vec<(isize, isize)> = Vec::new();
85aaf69f 17 let x: &[(isize, isize)] = &x;
3157f602 18 match *x {
223e47cc
LB
19 [a, (2, 3), _] => (),
20 [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
21 _ => ()
22 }
23
1a4d82fc
JJ
24 let x: Vec<String> = vec!["foo".to_string(),
25 "bar".to_string(),
26 "baz".to_string()];
85aaf69f 27 let x: &[String] = &x;
3157f602 28 match *x {
32a655c1 29 [ref a, _, _, ..] => { println!("{}", a); }
1a4d82fc 30 [_, _, _, _, _] => { } //~ ERROR unreachable pattern
223e47cc
LB
31 _ => { }
32 }
33
c30ab7b3 34 let x: Vec<char> = vec!['a', 'b', 'c'];
85aaf69f 35 let x: &[char] = &x;
3157f602
XL
36 match *x {
37 ['a', 'b', 'c', ref _tail..] => {}
223e47cc
LB
38 ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
39 _ => {}
40 }
41}