fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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