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.
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.
11 // Test that move restrictions are enforced on overloaded unary operations
15 fn move_then_borrow<T: Not<Output=T> + Clone>(x: T) {
18 x.clone(); //~ ERROR: use of moved value
21 fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) {
25 !x; //~ ERROR: cannot move out of `x` because it is borrowed
27 !y; //~ ERROR: cannot move out of `y` because it is borrowed
28 use_mut(n); use_imm(m);
30 fn illegal_dereference<T: Not<Output=T>>(mut x: T, y: T) {
34 !*m; //~ ERROR: cannot move out of borrowed content
36 !*n; //~ ERROR: cannot move out of borrowed content
37 use_imm(n); use_mut(m);
41 fn use_mut<T>(_: &mut T) { }
42 fn use_imm<T>(_: &T) { }