2018-08-01 14:40:06 -05:00
|
|
|
error[E0382]: use of moved value: `x`
|
2019-04-07 10:07:36 -05:00
|
|
|
--> $DIR/closures-in-loops.rs:6:9
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
2019-01-02 18:43:08 -06:00
|
|
|
LL | fn repreated_move(x: String) {
|
2020-09-02 02:40:56 -05:00
|
|
|
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
|
2019-01-02 18:43:08 -06:00
|
|
|
LL | for i in 0..10 {
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | || x;
|
2018-08-01 14:40:06 -05:00
|
|
|
| ^^ - use occurs due to use in closure
|
|
|
|
| |
|
2018-09-28 11:21:10 -05:00
|
|
|
| value moved into closure here, in previous iteration of loop
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2019-04-07 10:07:36 -05:00
|
|
|
--> $DIR/closures-in-loops.rs:13:16
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | v.push(|| x = String::new());
|
2022-09-20 16:44:55 -05:00
|
|
|
| -------^^-------------------
|
|
|
|
| | | |
|
|
|
|
| | | borrows occur due to use of `x` in closure
|
|
|
|
| | `x` was mutably borrowed here in the previous iteration of the loop
|
|
|
|
| first borrow used here, in later iteration of loop
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
|
|
error[E0524]: two closures require unique access to `x` at the same time
|
2019-04-07 10:07:36 -05:00
|
|
|
--> $DIR/closures-in-loops.rs:20:16
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | v.push(|| *x = String::new());
|
2022-09-20 16:44:55 -05:00
|
|
|
| -------^^--------------------
|
|
|
|
| | | |
|
|
|
|
| | | borrows occur due to use of `x` in closure
|
|
|
|
| | closures are constructed here in different iterations of loop
|
|
|
|
| first borrow used here, in later iteration of loop
|
2018-08-01 14:40:06 -05:00
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
|
2019-09-13 08:14:53 -05:00
|
|
|
Some errors have detailed explanations: E0382, E0499, E0524.
|
2018-08-01 14:40:06 -05:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|