]> git.lizzy.rs Git - rust.git/blob - tests/ui/binop/binop-move-semantics.stderr
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
[rust.git] / tests / ui / binop / binop-move-semantics.stderr
1 error[E0382]: use of moved value: `x`
2   --> $DIR/binop-move-semantics.rs:8:5
3    |
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
15   --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
16 help: consider further restricting this bound
17    |
18 LL | fn double_move<T: Add<Output=()> + Copy>(x: T) {
19    |                                  ++++++
20
21 error[E0382]: borrow of moved value: `x`
22   --> $DIR/binop-move-semantics.rs:14:5
23    |
24 LL | fn move_then_borrow<T: Add<Output=()> + Clone>(x: T) {
25    |                                                - move occurs because `x` has type `T`, which does not implement the `Copy` trait
26 LL |     x
27    |     - value moved here
28 LL |     +
29 LL |     x.clone();
30    |     ^^^^^^^^^ value borrowed here after move
31    |
32 help: consider cloning the value if the performance cost is acceptable
33    |
34 LL |     x.clone()
35    |      ++++++++
36 help: consider further restricting this bound
37    |
38 LL | fn move_then_borrow<T: Add<Output=()> + Clone + Copy>(x: T) {
39    |                                               ++++++
40
41 error[E0505]: cannot move out of `x` because it is borrowed
42   --> $DIR/binop-move-semantics.rs:21:5
43    |
44 LL |     let m = &x;
45    |             -- borrow of `x` occurs here
46 ...
47 LL |     x
48    |     ^ move out of `x` occurs here
49 ...
50 LL |     use_mut(n); use_imm(m);
51    |                         - borrow later used here
52
53 error[E0505]: cannot move out of `y` because it is borrowed
54   --> $DIR/binop-move-semantics.rs:23:5
55    |
56 LL |     let n = &mut y;
57    |             ------ borrow of `y` occurs here
58 ...
59 LL |     y;
60    |     ^ move out of `y` occurs here
61 LL |     use_mut(n); use_imm(m);
62    |             - borrow later used here
63
64 error[E0507]: cannot move out of `*m` which is behind a mutable reference
65   --> $DIR/binop-move-semantics.rs:30:5
66    |
67 LL |       *m
68    |       -^
69    |       |
70    |  _____move occurs because `*m` has type `T`, which does not implement the `Copy` trait
71    | |
72 LL | |     +
73 LL | |     *n;
74    | |______- `*m` moved due to usage in operator
75    |
76 note: calling this operator moves the left-hand side
77   --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
78
79 error[E0507]: cannot move out of `*n` which is behind a shared reference
80   --> $DIR/binop-move-semantics.rs:32:5
81    |
82 LL |     *n;
83    |     ^^ move occurs because `*n` has type `T`, which does not implement the `Copy` trait
84
85 error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
86   --> $DIR/binop-move-semantics.rs:54:5
87    |
88 LL |       &mut f
89    |       ------
90    |       |
91    |  _____mutable borrow occurs here
92    | |
93 LL | |     +
94 LL | |     &f;
95    | |     ^-
96    | |_____||
97    |       |mutable borrow later used here
98    |       immutable borrow occurs here
99
100 error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable
101   --> $DIR/binop-move-semantics.rs:62:5
102    |
103 LL |       &f
104    |       --
105    |       |
106    |  _____immutable borrow occurs here
107    | |
108 LL | |     +
109 LL | |     &mut f;
110    | |     ^^^^^-
111    | |_____|____|
112    |       |    immutable borrow later used here
113    |       mutable borrow occurs here
114
115 error: aborting due to 8 previous errors
116
117 Some errors have detailed explanations: E0382, E0502, E0505, E0507.
118 For more information about an error, try `rustc --explain E0382`.