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