@@ -66,7 +66,7 @@ error: the loop variable `i` is only used to index `vec2`
6666LL | for i in 0..vec.len() {
6767 | ^^^^^^^^^^^^
6868 |
69- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
69+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
7070help: consider using an iterator
7171 |
7272LL - for i in 0..vec.len() {
@@ -91,7 +91,7 @@ error: the loop variable `i` is only used to index `vec`
9191LL | for i in 0..MAX_LEN {
9292 | ^^^^^^^^^^
9393 |
94- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
94+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
9595help: consider using an iterator
9696 |
9797LL - for i in 0..MAX_LEN {
@@ -104,7 +104,7 @@ error: the loop variable `i` is only used to index `vec`
104104LL | for i in 0..=MAX_LEN {
105105 | ^^^^^^^^^^^
106106 |
107- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
107+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
108108help: consider using an iterator
109109 |
110110LL - for i in 0..=MAX_LEN {
@@ -117,7 +117,7 @@ error: the loop variable `i` is only used to index `vec`
117117LL | for i in 5..10 {
118118 | ^^^^^
119119 |
120- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
120+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
121121help: consider using an iterator
122122 |
123123LL - for i in 5..10 {
@@ -130,7 +130,7 @@ error: the loop variable `i` is only used to index `vec`
130130LL | for i in 5..=10 {
131131 | ^^^^^^
132132 |
133- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
133+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
134134help: consider using an iterator
135135 |
136136LL - for i in 5..=10 {
@@ -155,10 +155,11 @@ error: the loop variable `i` is used to index `vec`
155155LL | for i in 5..10 {
156156 | ^^^^^
157157 |
158+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
158159help: consider using an iterator and enumerate()
159160 |
160161LL - for i in 5..10 {
161- LL + for (i, <item>) in vec. iter().enumerate().take(10 ).skip(5) {
162+ LL + for (i, <item>) in vec[..10]. iter().enumerate().skip(5) {
162163 |
163164
164165error: the loop variable `i` is used to index `vec`
@@ -179,10 +180,11 @@ error: the loop variable `i` is used to index `a`
179180LL | for i in 0..MAX_LEN {
180181 | ^^^^^^^^^^
181182 |
183+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
182184help: consider using an iterator and enumerate()
183185 |
184186LL - for i in 0..MAX_LEN {
185- LL + for (i, <item>) in a. iter().enumerate().take(MAX_LEN ) {
187+ LL + for (i, <item>) in a[..MAX_LEN]. iter().enumerate() {
186188 |
187189
188190error: the loop variable `i` is only used to index `a`
@@ -191,12 +193,64 @@ error: the loop variable `i` is only used to index `a`
191193LL | for i in 0..MAX_LEN {
192194 | ^^^^^^^^^^
193195 |
194- = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the upper bound exceeds the collection length
196+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
195197help: consider using an iterator
196198 |
197199LL - for i in 0..MAX_LEN {
198200LL + for <item> in a[..MAX_LEN].iter() {
199201 |
200202
201- error: aborting due to 16 previous errors
203+ error: the loop variable `i` is only used to index `vec`
204+ --> tests/ui/needless_range_loop.rs:249:14
205+ |
206+ LL | for i in 0..=vec.len() {
207+ | ^^^^^^^^^^^^^
208+ |
209+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
210+ help: consider using an iterator
211+ |
212+ LL - for i in 0..=vec.len() {
213+ LL + for <item> in vec[..=vec.len()].iter() {
214+ |
215+
216+ error: the loop variable `i` is used to index `vec`
217+ --> tests/ui/needless_range_loop.rs:254:14
218+ |
219+ LL | for i in 0..=vec.len() {
220+ | ^^^^^^^^^^^^^
221+ |
222+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
223+ help: consider using an iterator and enumerate()
224+ |
225+ LL - for i in 0..=vec.len() {
226+ LL + for (i, <item>) in vec[..=vec.len()].iter().enumerate() {
227+ |
228+
229+ error: the loop variable `i` is only used to index `arr`
230+ --> tests/ui/needless_range_loop.rs:261:14
231+ |
232+ LL | for i in 0..4 {
233+ | ^^^^
234+ |
235+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
236+ help: consider using an iterator
237+ |
238+ LL - for i in 0..4 {
239+ LL + for <item> in arr[..4].iter() {
240+ |
241+
242+ error: the loop variable `i` is only used to index `arr`
243+ --> tests/ui/needless_range_loop.rs:266:14
244+ |
245+ LL | for i in 0..=3 {
246+ | ^^^^^
247+ |
248+ = note: this suggestion preserves panic behavior, but the panic will occur before iteration if the range end is out of bounds
249+ help: consider using an iterator
250+ |
251+ LL - for i in 0..=3 {
252+ LL + for <item> in arr[..=3].iter() {
253+ |
254+
255+ error: aborting due to 20 previous errors
202256
0 commit comments