File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
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 move restrictions are enforced on overloaded unary operations
12
+
13
+ fn move_then_borrow < T : Not < T > + Clone > ( x : T ) {
14
+ !x;
15
+
16
+ x. clone ( ) ; //~ ERROR: use of moved value
17
+ }
18
+
19
+ fn move_borrowed < T : Not < T > > ( x : T , mut y : T ) {
20
+ let m = & x;
21
+ let n = & mut y;
22
+
23
+ !x; //~ ERROR: cannot move out of `x` because it is borrowed
24
+
25
+ !y; //~ ERROR: cannot move out of `y` because it is borrowed
26
+ }
27
+
28
+ fn illegal_dereference < T : Not < T > > ( mut x : T , y : T ) {
29
+ let m = & mut x;
30
+ let n = & y;
31
+
32
+ !* m; //~ ERROR: cannot move out of dereference of `&mut`-pointer
33
+
34
+ !* n; //~ ERROR: cannot move out of dereference of `&`-pointer
35
+ }
36
+
37
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments