]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closures-in-loops.stderr
Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum
[rust.git] / src / test / ui / nll / closures-in-loops.stderr
1 error[E0382]: use of moved value: `x`
2   --> $DIR/closures-in-loops.rs:6:9
3    |
4 LL | fn repreated_move(x: String) {
5    |                   - move occurs because `x` has type `String`, which does not implement the `Copy` trait
6 LL |     for i in 0..10 {
7 LL |         || x;
8    |         ^^ - use occurs due to use in closure
9    |         |
10    |         value moved into closure here, in previous iteration of loop
11
12 error[E0499]: cannot borrow `x` as mutable more than once at a time
13   --> $DIR/closures-in-loops.rs:13:16
14    |
15 LL |         v.push(|| x = String::new());
16    |         -------^^-------------------
17    |         |      |  |
18    |         |      |  borrows occur due to use of `x` in closure
19    |         |      `x` was mutably borrowed here in the previous iteration of the loop
20    |         first borrow used here, in later iteration of loop
21
22 error[E0524]: two closures require unique access to `x` at the same time
23   --> $DIR/closures-in-loops.rs:20:16
24    |
25 LL |         v.push(|| *x = String::new());
26    |         -------^^--------------------
27    |         |      |  |
28    |         |      |  borrows occur due to use of `x` in closure
29    |         |      closures are constructed here in different iterations of loop
30    |         first borrow used here, in later iteration of loop
31
32 error: aborting due to 3 previous errors
33
34 Some errors have detailed explanations: E0382, E0499, E0524.
35 For more information about an error, try `rustc --explain E0382`.