Skip to content

Commit 2b17083

Browse files
author
Jorge Aparicio
committed
Test that binops consume their arguments
1 parent fb1d4f1 commit 2b17083

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
fn add<A: Add<B, ()>, B>(lhs: A, rhs: B) {
14+
lhs + rhs;
15+
drop(lhs); //~ ERROR use of moved value: `lhs`
16+
drop(rhs); //~ ERROR use of moved value: `rhs`
17+
}
18+
19+
fn sub<A: Sub<B, ()>, B>(lhs: A, rhs: B) {
20+
lhs - rhs;
21+
drop(lhs); //~ ERROR use of moved value: `lhs`
22+
drop(rhs); //~ ERROR use of moved value: `rhs`
23+
}
24+
25+
fn mul<A: Mul<B, ()>, B>(lhs: A, rhs: B) {
26+
lhs * rhs;
27+
drop(lhs); //~ ERROR use of moved value: `lhs`
28+
drop(rhs); //~ ERROR use of moved value: `rhs`
29+
}
30+
31+
fn div<A: Div<B, ()>, B>(lhs: A, rhs: B) {
32+
lhs / rhs;
33+
drop(lhs); //~ ERROR use of moved value: `lhs`
34+
drop(rhs); //~ ERROR use of moved value: `rhs`
35+
}
36+
37+
fn rem<A: Rem<B, ()>, B>(lhs: A, rhs: B) {
38+
lhs % rhs;
39+
drop(lhs); //~ ERROR use of moved value: `lhs`
40+
drop(rhs); //~ ERROR use of moved value: `rhs`
41+
}
42+
43+
fn bitand<A: BitAnd<B, ()>, B>(lhs: A, rhs: B) {
44+
lhs & rhs;
45+
drop(lhs); //~ ERROR use of moved value: `lhs`
46+
drop(rhs); //~ ERROR use of moved value: `rhs`
47+
}
48+
49+
fn bitor<A: BitOr<B, ()>, B>(lhs: A, rhs: B) {
50+
lhs | rhs;
51+
drop(lhs); //~ ERROR use of moved value: `lhs`
52+
drop(rhs); //~ ERROR use of moved value: `rhs`
53+
}
54+
55+
fn bitxor<A: BitXor<B, ()>, B>(lhs: A, rhs: B) {
56+
lhs ^ rhs;
57+
drop(lhs); //~ ERROR use of moved value: `lhs`
58+
drop(rhs); //~ ERROR use of moved value: `rhs`
59+
}
60+
61+
fn shl<A: Shl<B, ()>, B>(lhs: A, rhs: B) {
62+
lhs << rhs;
63+
drop(lhs); //~ ERROR use of moved value: `lhs`
64+
drop(rhs); //~ ERROR use of moved value: `rhs`
65+
}
66+
67+
fn shr<A: Shr<B, ()>, B>(lhs: A, rhs: B) {
68+
lhs >> rhs;
69+
drop(lhs); //~ ERROR use of moved value: `lhs`
70+
drop(rhs); //~ ERROR use of moved value: `rhs`
71+
}
72+
73+
fn main() {}

0 commit comments

Comments
 (0)