Do not suggest moving expression out of for loop when hitting break… · rust-lang/rust@c60ed21 (original) (raw)
1
1
`` error[E0382]: use of moved value: foo
``
2
``
`-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:21:14
`
``
2
`+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:19:14
`
3
3
` |
`
4
4
`LL | for foo in foos { for bar in &bars { if foo == *bar {
`
5
5
` | --- ---------------- inside of this loop
`
`@@ -14,29 +14,20 @@ LL | qux.push(foo);
`
14
14
` | ^^^ value used here after move
`
15
15
` |
`
16
16
`note: verify that your loop breaking logic is correct
`
17
``
`-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:17:9
`
``
17
`+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:15:9
`
18
18
` |
`
19
19
`LL | for foo in foos { for bar in &bars { if foo == *bar {
`
20
20
` | --------------- ----------------
`
21
21
`...
`
22
22
`LL | continue;
`
23
``
`` -
| ^^^^^^^^ this continue advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 20:8
``
24
``
`-
help: consider moving the expression out of the loop so it is only moved once
`
25
``
`-
|
`
26
``
`-
LL ~ for foo in foos { let mut value = baz.push(foo);
`
27
``
`-
LL ~ for bar in &bars { if foo == *bar {
`
28
``
`-
LL |
`
29
``
`-
...
`
30
``
`-
LL |
`
31
``
`-
LL ~ value;
`
32
``
`-
|
`
``
23
`` +
| ^^^^^^^^ this continue advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 18:8
``
33
24
`help: consider cloning the value if the performance cost is acceptable
`
34
25
` |
`
35
26
`LL | baz.push(foo.clone());
`
36
27
` | ++++++++
`
37
28
``
38
29
`` error[E0382]: use of moved value: foo
``
39
``
`-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:50:18
`
``
30
`+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:46:18
`
40
31
` |
`
41
32
`LL | for foo in foos {
`
42
33
` | ---
`
`@@ -54,7 +45,7 @@ LL | qux.push(foo);
`
54
45
` | ^^^ value used here after move
`
55
46
` |
`
56
47
`note: verify that your loop breaking logic is correct
`
57
``
`-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:45:17
`
``
48
`+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:41:17
`
58
49
` |
`
59
50
`LL | for foo in foos {
`
60
51
` | ---------------
`
`@@ -63,16 +54,7 @@ LL | for bar in &bars {
`
63
54
` | ----------------
`
64
55
`...
`
65
56
`LL | continue;
`
66
``
`` -
| ^^^^^^^^ this continue advances the loop at line 36
``
67
``
`-
help: consider moving the expression out of the loop so it is only moved once
`
68
``
`-
|
`
69
``
`-
LL ~ let mut value = baz.push(foo);
`
70
``
`-
LL ~ for bar in &bars {
`
71
``
`-
LL |
`
72
``
`-
...
`
73
``
`-
LL | if foo == *bar {
`
74
``
`-
LL ~ value;
`
75
``
`-
|
`
``
57
`` +
| ^^^^^^^^ this continue advances the loop at line 34
``
76
58
`help: consider cloning the value if the performance cost is acceptable
`
77
59
` |
`
78
60
`LL | baz.push(foo.clone());
`