@@ -23,12 +23,13 @@ LL ~ while let Some(item) = value.next() {
2323 |
2424
2525error[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
2727 |
2828LL | let vec = vec!["one", "two", "three"];
2929 | --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
3030LL | loop {
3131 | ---- inside of this loop
32+ LL |
3233LL | let Some(item) = iter(vec).next() else {
3334 | ^^^ value moved here, in previous iteration of loop
3435 |
@@ -43,16 +44,18 @@ help: consider moving the expression out of the loop so it is only moved once
4344 |
4445LL ~ let mut value = iter(vec);
4546LL ~ loop {
47+ LL |
4648LL ~ let Some(item) = value.next() else {
4749 |
4850
4951error[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
5153 |
5254LL | let vec = vec!["one", "two", "three"];
5355 | --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
5456LL | loop {
5557 | ---- inside of this loop
58+ LL |
5659LL | let item = iter(vec).next();
5760 | ^^^ value moved here, in previous iteration of loop
5861 |
@@ -67,6 +70,7 @@ help: consider moving the expression out of the loop so it is only moved once
6770 |
6871LL ~ let mut value = iter(vec);
6972LL ~ loop {
73+ LL |
7074LL ~ let item = value.next();
7175 |
7276help: consider cloning the value if the performance cost is acceptable
@@ -75,12 +79,13 @@ LL | let item = iter(vec.clone()).next();
7579 | ++++++++
7680
7781error[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
7983 |
8084LL | let vec = vec!["one", "two", "three"];
8185 | --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
8286LL | loop {
8387 | ---- inside of this loop
88+ LL |
8489LL | if let Some(item) = iter(vec).next() {
8590 | ^^^ value moved here, in previous iteration of loop
8691 |
@@ -95,16 +100,18 @@ help: consider moving the expression out of the loop so it is only moved once
95100 |
96101LL ~ let mut value = iter(vec);
97102LL ~ loop {
103+ LL |
98104LL ~ if let Some(item) = value.next() {
99105 |
100106
101107error[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
103109 |
104110LL | let vec = vec!["one", "two", "three"];
105111 | --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
106112LL | loop {
107113 | ---- inside of this loop
114+ LL |
108115LL | loop {
109116 | ---- inside of this loop
110117LL | loop {
@@ -120,24 +127,26 @@ LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
120127 | |
121128 | in this function
122129note: 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
124131 |
125132LL | loop {
126133 | ----
127134LL | let vec = vec!["one", "two", "three"];
128135LL | loop {
129136 | ----
137+ LL |
130138LL | loop {
131139 | ----
132140LL | loop {
133141 | ----
134142...
135143LL | break;
136- | ^^^^^ this `break` exits the loop at line 43
144+ | ^^^^^ this `break` exits the loop at line 49
137145help: consider moving the expression out of the loop so it is only moved once
138146 |
139147LL ~ let mut value = iter(vec);
140148LL ~ loop {
149+ LL |
141150LL | loop {
142151LL | loop {
143152LL ~ if let Some(item) = value.next() {
0 commit comments