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