fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
2.9 KiB95 linesraw
1error[E0382]: use of moved value: `x`
2  --> $DIR/binop-move-semantics.rs:8:5
3   |
4LL | fn double_move<T: Add<Output=()>>(x: T) {
5   |                -                  - move occurs because `x` has type `T`, which does not implement the `Copy` trait
6   |                |
7   |                consider adding a `Copy` constraint to this type argument
8LL |     x
9   |     - value moved here
10LL |     +
11LL |     x;
12   |     ^ value used here after move
13
14error[E0382]: borrow of moved value: `x`
15  --> $DIR/binop-move-semantics.rs:14:5
16   |
17LL | fn move_then_borrow<T: Add<Output=()> + Clone>(x: T) {
18   |                     -                          - move occurs because `x` has type `T`, which does not implement the `Copy` trait
19   |                     |
20   |                     consider adding a `Copy` constraint to this type argument
21LL |     x
22   |     - value moved here
23LL |     +
24LL |     x.clone();
25   |     ^ value borrowed here after move
26
27error[E0505]: cannot move out of `x` because it is borrowed
28  --> $DIR/binop-move-semantics.rs:21:5
29   |
30LL |     let m = &x;
31   |             -- borrow of `x` occurs here
32...
33LL |     x
34   |     ^ move out of `x` occurs here
35...
36LL |     use_mut(n); use_imm(m);
37   |                         - borrow later used here
38
39error[E0505]: cannot move out of `y` because it is borrowed
40  --> $DIR/binop-move-semantics.rs:23:5
41   |
42LL |     let n = &mut y;
43   |             ------ borrow of `y` occurs here
44...
45LL |     y;
46   |     ^ move out of `y` occurs here
47LL |     use_mut(n); use_imm(m);
48   |             - borrow later used here
49
50error[E0507]: cannot move out of `*m` which is behind a mutable reference
51  --> $DIR/binop-move-semantics.rs:30:5
52   |
53LL |     *m
54   |     ^^ move occurs because `*m` has type `T`, which does not implement the `Copy` trait
55
56error[E0507]: cannot move out of `*n` which is behind a shared reference
57  --> $DIR/binop-move-semantics.rs:32:5
58   |
59LL |     *n;
60   |     ^^ move occurs because `*n` has type `T`, which does not implement the `Copy` trait
61
62error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
63  --> $DIR/binop-move-semantics.rs:54:5
64   |
65LL |       &mut f
66   |       ------
67   |       |
68   |  _____mutable borrow occurs here
69   | |
70LL | |     +
71LL | |     &f;
72   | |     ^-
73   | |_____||
74   |       |mutable borrow later used here
75   |       immutable borrow occurs here
76
77error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable
78  --> $DIR/binop-move-semantics.rs:62:5
79   |
80LL |       &f
81   |       --
82   |       |
83   |  _____immutable borrow occurs here
84   | |
85LL | |     +
86LL | |     &mut f;
87   | |     ^^^^^-
88   | |_____|____|
89   |       |    immutable borrow later used here
90   |       mutable borrow occurs here
91
92error: aborting due to 8 previous errors
93
94Some errors have detailed explanations: E0382, E0502, E0505, E0507.
95For more information about an error, try `rustc --explain E0382`.