]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/move-guard-same-consts.rs
Move /src/test to /tests
[rust.git] / tests / ui / moves / move-guard-same-consts.rs
1 // #47295: We used to have a hack of special-casing adjacent amtch
2 // arms whose patterns were composed solely of constants to not have
3 // them linked in the cfg.
4 //
5 // This was broken for various reasons. In particular, that hack was
6 // originally authored under the assunption that other checks
7 // elsewhere would ensure that the two patterns did not overlap.  But
8 // that assumption did not hold, at least not in the long run (namely,
9 // overlapping patterns were turned into warnings rather than errors).
10
11
12
13 fn main() {
14     let x: Box<_> = Box::new(1);
15
16     let v = (1, 2);
17
18     match v {
19         (1, 2) if take(x) => (),
20         (1, 2) if take(x) => (), //~ ERROR use of moved value: `x`
21         _ => (),
22     }
23 }
24
25 fn take<T>(_: T) -> bool { false }