]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | error[E0382]: use of moved value: `x` |
0731742a | 2 | --> $DIR/binop-move-semantics.rs:8:5 |
b7449926 | 3 | | |
f035d41b XL |
4 | LL | fn double_move<T: Add<Output=()>>(x: T) { |
5 | | - move occurs because `x` has type `T`, which does not implement the `Copy` trait | |
6 | LL | / x | |
7 | LL | | + | |
8 | LL | | x; | |
9 | | | ^ | |
10 | | | | | |
11 | | |_____value used here after move | |
12 | | `x` moved due to usage in operator | |
13 | | | |
14 | note: calling this operator moves the left-hand side | |
3dfed10e | 15 | --> $SRC_DIR/core/src/ops/arith.rs:LL:COL |
74b04a01 | 16 | | |
f035d41b XL |
17 | LL | fn add(self, rhs: Rhs) -> Self::Output; |
18 | | ^^^^ | |
ba9703b0 | 19 | help: consider further restricting this bound |
74b04a01 | 20 | | |
ba9703b0 | 21 | LL | fn double_move<T: Add<Output=()> + Copy>(x: T) { |
94222f64 | 22 | | ++++++ |
b7449926 | 23 | |
48663c56 | 24 | error[E0382]: borrow of moved value: `x` |
0731742a | 25 | --> $DIR/binop-move-semantics.rs:14:5 |
b7449926 | 26 | | |
48663c56 | 27 | LL | fn move_then_borrow<T: Add<Output=()> + Clone>(x: T) { |
74b04a01 | 28 | | - move occurs because `x` has type `T`, which does not implement the `Copy` trait |
b7449926 XL |
29 | LL | x |
30 | | - value moved here | |
31 | LL | + | |
532ac7d7 | 32 | LL | x.clone(); |
c295e0f8 | 33 | | ^^^^^^^^^ value borrowed here after move |
74b04a01 | 34 | | |
ba9703b0 | 35 | help: consider further restricting this bound |
74b04a01 | 36 | | |
ba9703b0 | 37 | LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) { |
94222f64 | 38 | | ++++++ |
b7449926 XL |
39 | |
40 | error[E0505]: cannot move out of `x` because it is borrowed | |
0731742a | 41 | --> $DIR/binop-move-semantics.rs:21:5 |
b7449926 XL |
42 | | |
43 | LL | let m = &x; | |
48663c56 | 44 | | -- borrow of `x` occurs here |
b7449926 | 45 | ... |
532ac7d7 | 46 | LL | x |
b7449926 | 47 | | ^ move out of `x` occurs here |
48663c56 XL |
48 | ... |
49 | LL | use_mut(n); use_imm(m); | |
50 | | - borrow later used here | |
b7449926 XL |
51 | |
52 | error[E0505]: cannot move out of `y` because it is borrowed | |
0731742a | 53 | --> $DIR/binop-move-semantics.rs:23:5 |
b7449926 XL |
54 | | |
55 | LL | let n = &mut y; | |
48663c56 | 56 | | ------ borrow of `y` occurs here |
b7449926 | 57 | ... |
532ac7d7 | 58 | LL | y; |
b7449926 | 59 | | ^ move out of `y` occurs here |
48663c56 XL |
60 | LL | use_mut(n); use_imm(m); |
61 | | - borrow later used here | |
b7449926 | 62 | |
dc9dc135 | 63 | error[E0507]: cannot move out of `*m` which is behind a mutable reference |
0731742a | 64 | --> $DIR/binop-move-semantics.rs:30:5 |
b7449926 | 65 | | |
064997fb FG |
66 | LL | *m |
67 | | -^ | |
68 | | | | |
69 | | _____move occurs because `*m` has type `T`, which does not implement the `Copy` trait | |
70 | | | | |
71 | LL | | + | |
72 | LL | | *n; | |
73 | | |______- `*m` moved due to usage in operator | |
74 | | | |
75 | note: calling this operator moves the left-hand side | |
76 | --> $SRC_DIR/core/src/ops/arith.rs:LL:COL | |
77 | | | |
78 | LL | fn add(self, rhs: Rhs) -> Self::Output; | |
79 | | ^^^^ | |
b7449926 | 80 | |
dc9dc135 | 81 | error[E0507]: cannot move out of `*n` which is behind a shared reference |
0731742a | 82 | --> $DIR/binop-move-semantics.rs:32:5 |
b7449926 | 83 | | |
532ac7d7 | 84 | LL | *n; |
dc9dc135 | 85 | | ^^ move occurs because `*n` has type `T`, which does not implement the `Copy` trait |
b7449926 XL |
86 | |
87 | error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable | |
48663c56 | 88 | --> $DIR/binop-move-semantics.rs:54:5 |
b7449926 | 89 | | |
48663c56 XL |
90 | LL | &mut f |
91 | | ------ | |
92 | | | | |
93 | | _____mutable borrow occurs here | |
94 | | | | |
95 | LL | | + | |
96 | LL | | &f; | |
97 | | | ^- | |
98 | | |_____|| | |
99 | | |mutable borrow later used here | |
100 | | immutable borrow occurs here | |
b7449926 XL |
101 | |
102 | error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable | |
48663c56 | 103 | --> $DIR/binop-move-semantics.rs:62:5 |
b7449926 | 104 | | |
48663c56 XL |
105 | LL | &f |
106 | | -- | |
107 | | | | |
108 | | _____immutable borrow occurs here | |
109 | | | | |
110 | LL | | + | |
111 | LL | | &mut f; | |
112 | | | ^^^^^- | |
113 | | |_____|____| | |
114 | | | immutable borrow later used here | |
115 | | mutable borrow occurs here | |
b7449926 XL |
116 | |
117 | error: aborting due to 8 previous errors | |
118 | ||
48663c56 | 119 | Some errors have detailed explanations: E0382, E0502, E0505, E0507. |
b7449926 | 120 | For more information about an error, try `rustc --explain E0382`. |