mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Update test to show incorrecct +=
clone suggestion
This commit is contained in:
parent
a1a3abb08f
commit
b83ebea5de
@ -1,5 +1,6 @@
|
||||
use std::ops::AddAssign;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Int(i32);
|
||||
|
||||
impl AddAssign for Int {
|
||||
@ -12,6 +13,7 @@ fn main() {
|
||||
let mut x = Int(1); //~ NOTE binding `x` declared here
|
||||
x
|
||||
//~^ NOTE borrow of `x` occurs here
|
||||
//~| HELP consider cloning
|
||||
+=
|
||||
x;
|
||||
//~^ ERROR cannot move out of `x` because it is borrowed
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/augmented-assignments.rs:16:5
|
||||
--> $DIR/augmented-assignments.rs:17:5
|
||||
|
|
||||
LL | let mut x = Int(1);
|
||||
| ----- binding `x` declared here
|
||||
@ -8,9 +8,14 @@ LL | x
|
||||
...
|
||||
LL | x;
|
||||
| ^ move out of `x` occurs here
|
||||
|
|
||||
help: consider cloning the value if the performance cost is acceptable
|
||||
|
|
||||
LL | x.clone()
|
||||
| ++++++++
|
||||
|
||||
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
||||
--> $DIR/augmented-assignments.rs:23:5
|
||||
--> $DIR/augmented-assignments.rs:25:5
|
||||
|
|
||||
LL | y
|
||||
| ^ cannot borrow as mutable
|
||||
|
Loading…
Reference in New Issue
Block a user