-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4691 - HMPerson1:suggest_iter, r=phansch
Fix suggestion of `explicit_counter_loop` changelog: In the suggestion of `explicit_counter_loop`, if the `for` loop argument doesn't implement `Iterator`, then we suggest `x.into_iter().enumerate()` (or `x.iter{_mut}()` as appropriate). Also, the span of the suggestion has been corrected. Fixes #4678
- Loading branch information
Showing
4 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
error: the variable `_index` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:6:15 | ||
--> $DIR/explicit_counter_loop.rs:6:5 | ||
| | ||
LL | for _v in &vec { | ||
| ^^^^ help: consider using: `for (_index, _v) in (&vec).enumerate()` | ||
| ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` | ||
| | ||
= note: `-D clippy::explicit-counter-loop` implied by `-D warnings` | ||
|
||
error: the variable `_index` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:12:15 | ||
--> $DIR/explicit_counter_loop.rs:12:5 | ||
| | ||
LL | for _v in &vec { | ||
| ^^^^ help: consider using: `for (_index, _v) in (&vec).enumerate()` | ||
| ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` | ||
|
||
error: the variable `_index` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:17:5 | ||
| | ||
LL | for _v in &mut vec { | ||
| ^^^^^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter_mut().enumerate()` | ||
|
||
error: the variable `_index` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:22:5 | ||
| | ||
LL | for _v in vec { | ||
| ^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.into_iter().enumerate()` | ||
|
||
error: the variable `count` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:51:19 | ||
--> $DIR/explicit_counter_loop.rs:61:9 | ||
| | ||
LL | for ch in text.chars() { | ||
| ^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` | ||
|
||
error: the variable `count` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:62:19 | ||
--> $DIR/explicit_counter_loop.rs:72:9 | ||
| | ||
LL | for ch in text.chars() { | ||
| ^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` | ||
|
||
error: the variable `count` is used as a loop counter. | ||
--> $DIR/explicit_counter_loop.rs:120:19 | ||
--> $DIR/explicit_counter_loop.rs:130:9 | ||
| | ||
LL | for _i in 3..10 { | ||
| ^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` | ||
| ^^^^^^^^^^^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` | ||
|
||
error: aborting due to 5 previous errors | ||
error: aborting due to 7 previous errors | ||
|