@@ -23,12 +23,13 @@ LL ~ while let Some(item) = value.next() {
23
23
|
24
24
25
25
error[E0382]: use of moved value: `vec`
26
- --> $DIR/recreating-value-in-loop-condition.rs:13 :31
26
+ --> $DIR/recreating-value-in-loop-condition.rs:15 :31
27
27
|
28
28
LL | let vec = vec!["one", "two", "three"];
29
29
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
30
30
LL | loop {
31
31
| ---- inside of this loop
32
+ LL |
32
33
LL | let Some(item) = iter(vec).next() else {
33
34
| ^^^ value moved here, in previous iteration of loop
34
35
|
@@ -43,16 +44,18 @@ help: consider moving the expression out of the loop so it is only moved once
43
44
|
44
45
LL ~ let mut value = iter(vec);
45
46
LL ~ loop {
47
+ LL |
46
48
LL ~ let Some(item) = value.next() else {
47
49
|
48
50
49
51
error[E0382]: use of moved value: `vec`
50
- --> $DIR/recreating-value-in-loop-condition.rs:22 :25
52
+ --> $DIR/recreating-value-in-loop-condition.rs:25 :25
51
53
|
52
54
LL | let vec = vec!["one", "two", "three"];
53
55
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
54
56
LL | loop {
55
57
| ---- inside of this loop
58
+ LL |
56
59
LL | let item = iter(vec).next();
57
60
| ^^^ value moved here, in previous iteration of loop
58
61
|
@@ -67,6 +70,7 @@ help: consider moving the expression out of the loop so it is only moved once
67
70
|
68
71
LL ~ let mut value = iter(vec);
69
72
LL ~ loop {
73
+ LL |
70
74
LL ~ let item = value.next();
71
75
|
72
76
help: consider cloning the value if the performance cost is acceptable
@@ -75,12 +79,13 @@ LL | let item = iter(vec.clone()).next();
75
79
| ++++++++
76
80
77
81
error[E0382]: use of moved value: `vec`
78
- --> $DIR/recreating-value-in-loop-condition.rs:32 :34
82
+ --> $DIR/recreating-value-in-loop-condition.rs:37 :34
79
83
|
80
84
LL | let vec = vec!["one", "two", "three"];
81
85
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
82
86
LL | loop {
83
87
| ---- inside of this loop
88
+ LL |
84
89
LL | if let Some(item) = iter(vec).next() {
85
90
| ^^^ value moved here, in previous iteration of loop
86
91
|
@@ -95,16 +100,18 @@ help: consider moving the expression out of the loop so it is only moved once
95
100
|
96
101
LL ~ let mut value = iter(vec);
97
102
LL ~ loop {
103
+ LL |
98
104
LL ~ if let Some(item) = value.next() {
99
105
|
100
106
101
107
error[E0382]: use of moved value: `vec`
102
- --> $DIR/recreating-value-in-loop-condition.rs:44 :46
108
+ --> $DIR/recreating-value-in-loop-condition.rs:50 :46
103
109
|
104
110
LL | let vec = vec!["one", "two", "three"];
105
111
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
106
112
LL | loop {
107
113
| ---- inside of this loop
114
+ LL |
108
115
LL | loop {
109
116
| ---- inside of this loop
110
117
LL | loop {
@@ -120,24 +127,26 @@ LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
120
127
| |
121
128
| in this function
122
129
note: verify that your loop breaking logic is correct
123
- --> $DIR/recreating-value-in-loop-condition.rs:46 :25
130
+ --> $DIR/recreating-value-in-loop-condition.rs:52 :25
124
131
|
125
132
LL | loop {
126
133
| ----
127
134
LL | let vec = vec!["one", "two", "three"];
128
135
LL | loop {
129
136
| ----
137
+ LL |
130
138
LL | loop {
131
139
| ----
132
140
LL | loop {
133
141
| ----
134
142
...
135
143
LL | break;
136
- | ^^^^^ this `break` exits the loop at line 43
144
+ | ^^^^^ this `break` exits the loop at line 49
137
145
help: consider moving the expression out of the loop so it is only moved once
138
146
|
139
147
LL ~ let mut value = iter(vec);
140
148
LL ~ loop {
149
+ LL |
141
150
LL | loop {
142
151
LL | loop {
143
152
LL ~ if let Some(item) = value.next() {
0 commit comments