File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
use std:: ops:: AddAssign ;
2
2
3
+ #[ derive( Clone ) ]
3
4
struct Int ( i32 ) ;
4
5
5
6
impl AddAssign for Int {
@@ -12,6 +13,7 @@ fn main() {
12
13
let mut x = Int ( 1 ) ; //~ NOTE binding `x` declared here
13
14
x
14
15
//~^ NOTE borrow of `x` occurs here
16
+ //~| HELP consider cloning
15
17
+=
16
18
x;
17
19
//~^ ERROR cannot move out of `x` because it is borrowed
Original file line number Diff line number Diff line change 1
1
error[E0505]: cannot move out of `x` because it is borrowed
2
- --> $DIR/augmented-assignments.rs:16 :5
2
+ --> $DIR/augmented-assignments.rs:17 :5
3
3
|
4
4
LL | let mut x = Int(1);
5
5
| ----- binding `x` declared here
8
8
...
9
9
LL | x;
10
10
| ^ move out of `x` occurs here
11
+ |
12
+ help: consider cloning the value if the performance cost is acceptable
13
+ |
14
+ LL | x.clone()
15
+ | ++++++++
11
16
12
17
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
13
- --> $DIR/augmented-assignments.rs:23 :5
18
+ --> $DIR/augmented-assignments.rs:25 :5
14
19
|
15
20
LL | y
16
21
| ^ cannot borrow as mutable
You can’t perform that action at this time.
0 commit comments