rust/tests/ui/nll/closures-in-loops.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.4 KiB
Plaintext
Raw Normal View History

2018-08-01 19:40:06 +00:00
error[E0382]: use of moved value: `x`
--> $DIR/closures-in-loops.rs:6:9
2018-08-01 19:40:06 +00:00
|
LL | fn repreated_move(x: String) {
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
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
| |
| 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
--> $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());
| -------^^-------------------
| | | |
| | | 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 19:40:06 +00:00
error[E0524]: two closures require unique access to `x` at the same time
--> $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());
| -------^^--------------------
| | | |
| | | 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 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`.