summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/closures-in-loops.stderr
blob: 2be0460df1fc67eaae9b4c1b1c4c758c058c4772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
error[E0382]: use of moved value: `x`
  --> $DIR/closures-in-loops.rs:6:9
   |
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 {
LL |         || x;
   |         ^^ - 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:13:16
   |
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

error[E0524]: two closures require unique access to `x` at the same time
  --> $DIR/closures-in-loops.rs:20:16
   |
LL |         v.push(|| *x = String::new());
   |                ^^ -- 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 have detailed explanations: E0382, E0499, E0524.
For more information about an error, try `rustc --explain E0382`.