]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/issue-31221.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-31221.rs
CommitLineData
a7813a04
XL
1// Copyright 2016 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
11enum Enum {
12 Var1,
13 Var2,
14}
15
16fn main() {
17 use Enum::*;
18 let s = Var1;
19 match s {
20 Var1 => (),
21 Var3 => (),
22 //~^ NOTE this pattern matches any value
23 Var2 => (),
24 //~^ ERROR unreachable pattern
5bcae85e 25 //~^^ NOTE this is an unreachable pattern
a7813a04
XL
26 };
27 match &s {
28 &Var1 => (),
29 &Var3 => (),
30 //~^ NOTE this pattern matches any value
31 &Var2 => (),
32 //~^ ERROR unreachable pattern
5bcae85e 33 //~^^ NOTE this is an unreachable pattern
a7813a04
XL
34 };
35 let t = (Var1, Var1);
36 match t {
37 (Var1, b) => (),
38 (c, d) => (),
39 //~^ NOTE this pattern matches any value
40 anything => ()
41 //~^ ERROR unreachable pattern
5bcae85e 42 //~^^ NOTE this is an unreachable pattern
a7813a04
XL
43 };
44 // `_` need not emit a note, it is pretty obvious already.
45 let t = (Var1, Var1);
46 match t {
47 (Var1, b) => (),
48 _ => (),
49 anything => ()
50 //~^ ERROR unreachable pattern
5bcae85e 51 //~^^ NOTE this is an unreachable pattern
a7813a04
XL
52 };
53}