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 11use std:: ops:: AddAssign ;
22
3+ #[ derive( Clone ) ]
34struct Int ( i32 ) ;
45
56impl AddAssign for Int {
@@ -12,6 +13,7 @@ fn main() {
1213 let mut x = Int ( 1 ) ; //~ NOTE binding `x` declared here
1314 x
1415 //~^ NOTE borrow of `x` occurs here
16+ //~| HELP consider cloning
1517 +=
1618 x;
1719 //~^ ERROR cannot move out of `x` because it is borrowed
Original file line number Diff line number Diff line change 11error[E0505]: cannot move out of `x` because it is borrowed
2- --> $DIR/augmented-assignments.rs:16 :5
2+ --> $DIR/augmented-assignments.rs:17 :5
33 |
44LL | let mut x = Int(1);
55 | ----- binding `x` declared here
88...
99LL | x;
1010 | ^ 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+ | ++++++++
1116
1217error[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
1419 |
1520LL | y
1621 | ^ cannot borrow as mutable
You can’t perform that action at this time.
0 commit comments