]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/binop-consume-args.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / compile-fail / binop-consume-args.rs
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
11 // Test that binary operators consume their arguments
12
13 use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr};
14
15 fn add<A: Add<B, Output=()>, B>(lhs: A, rhs: B) {
16 lhs + rhs;
17 drop(lhs); //~ ERROR use of moved value: `lhs`
18 drop(rhs); //~ ERROR use of moved value: `rhs`
19 }
20
21 fn sub<A: Sub<B, Output=()>, B>(lhs: A, rhs: B) {
22 lhs - rhs;
23 drop(lhs); //~ ERROR use of moved value: `lhs`
24 drop(rhs); //~ ERROR use of moved value: `rhs`
25 }
26
27 fn mul<A: Mul<B, Output=()>, B>(lhs: A, rhs: B) {
28 lhs * rhs;
29 drop(lhs); //~ ERROR use of moved value: `lhs`
30 drop(rhs); //~ ERROR use of moved value: `rhs`
31 }
32
33 fn div<A: Div<B, Output=()>, B>(lhs: A, rhs: B) {
34 lhs / rhs;
35 drop(lhs); //~ ERROR use of moved value: `lhs`
36 drop(rhs); //~ ERROR use of moved value: `rhs`
37 }
38
39 fn rem<A: Rem<B, Output=()>, B>(lhs: A, rhs: B) {
40 lhs % rhs;
41 drop(lhs); //~ ERROR use of moved value: `lhs`
42 drop(rhs); //~ ERROR use of moved value: `rhs`
43 }
44
45 fn bitand<A: BitAnd<B, Output=()>, B>(lhs: A, rhs: B) {
46 lhs & rhs;
47 drop(lhs); //~ ERROR use of moved value: `lhs`
48 drop(rhs); //~ ERROR use of moved value: `rhs`
49 }
50
51 fn bitor<A: BitOr<B, Output=()>, B>(lhs: A, rhs: B) {
52 lhs | rhs;
53 drop(lhs); //~ ERROR use of moved value: `lhs`
54 drop(rhs); //~ ERROR use of moved value: `rhs`
55 }
56
57 fn bitxor<A: BitXor<B, Output=()>, B>(lhs: A, rhs: B) {
58 lhs ^ rhs;
59 drop(lhs); //~ ERROR use of moved value: `lhs`
60 drop(rhs); //~ ERROR use of moved value: `rhs`
61 }
62
63 fn shl<A: Shl<B, Output=()>, B>(lhs: A, rhs: B) {
64 lhs << rhs;
65 drop(lhs); //~ ERROR use of moved value: `lhs`
66 drop(rhs); //~ ERROR use of moved value: `rhs`
67 }
68
69 fn shr<A: Shr<B, Output=()>, B>(lhs: A, rhs: B) {
70 lhs >> rhs;
71 drop(lhs); //~ ERROR use of moved value: `lhs`
72 drop(rhs); //~ ERROR use of moved value: `rhs`
73 }
74
75 fn main() {}