]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/move-guard-same-consts.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / test / compile-fail / move-guard-same-consts.rs
1 // Copyright 2015 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
11 // #47295: We used to have a hack of special-casing adjacent amtch
12 // arms whose patterns were composed solely of constants to not have
13 // them linked in the cfg.
14 //
15 // THis was broken for various reasons. In particular, that hack was
16 // originally authored under the assunption that other checks
17 // elsewhere would ensure that the two patterns did not overlap. But
18 // that assumption did not hold, at least not in the long run (namely,
19 // overlapping patterns were turned into warnings rather than errors).
20
21 #![feature(box_syntax)]
22
23 fn main() {
24 let x: Box<_> = box 1;
25
26 let v = (1, 2);
27
28 match v {
29 (1, 2) if take(x) => (),
30 (1, 2) if take(x) => (), //~ ERROR use of moved value: `x`
31 _ => (),
32 }
33 }
34
35 fn take<T>(_: T) -> bool { false }