5e9c8d7369
When trying to use a value after move, instead of using a note, point at the local declaration that has a type that doesn't implement `Copy` trait.
32 lines
1.2 KiB
Plaintext
32 lines
1.2 KiB
Plaintext
error[E0382]: use of moved value: `x`
|
|
--> $DIR/closures-in-loops.rs:8:9
|
|
|
|
|
LL | fn repreated_move(x: String) {
|
|
| - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
|
|
LL | for i in 0..10 {
|
|
LL | || x; //~ ERROR
|
|
| ^^ - use occurs due to use in closure
|
|
| |
|
|
| value moved into closure here, in previous iteration of loop
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
--> $DIR/closures-in-loops.rs:15:16
|
|
|
|
|
LL | v.push(|| x = String::new()); //~ ERROR
|
|
| ^^ - borrows occur due to use of `x` in closure
|
|
| |
|
|
| mutable borrow starts here in previous iteration of loop
|
|
|
|
error[E0524]: two closures require unique access to `x` at the same time
|
|
--> $DIR/closures-in-loops.rs:22:16
|
|
|
|
|
LL | v.push(|| *x = String::new()); //~ ERROR
|
|
| ^^ - borrows occur due to use of `x` in closure
|
|
| |
|
|
| closures are constructed here in different iterations of loop
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
Some errors occurred: E0382, E0499, E0524.
|
|
For more information about an error, try `rustc --explain E0382`.
|