1 // Test that move restrictions are enforced on overloaded binary operations
5 fn double_move<T: Add<Output=()>>(x: T) {
8 x; //~ ERROR: use of moved value
11 fn move_then_borrow<T: Add<Output=()> + Clone>(x: T) {
14 x.clone(); //~ ERROR: borrow of moved value
17 fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
21 x //~ ERROR: cannot move out of `x` because it is borrowed
23 y; //~ ERROR: cannot move out of `y` because it is borrowed
24 use_mut(n); use_imm(m);
26 fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
30 *m //~ ERROR: cannot move
32 *n; //~ ERROR: cannot move
33 use_imm(n); use_mut(m);
37 impl<'a, 'b> Add<&'b Foo> for &'a mut Foo {
40 fn add(self, _: &Foo) {}
43 impl<'a, 'b> Add<&'b mut Foo> for &'a Foo {
46 fn add(self, _: &mut Foo) {}
54 &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
62 &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable
67 fn use_mut<T>(_: &mut T) { }
68 fn use_imm<T>(_: &T) { }