-
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.
Add linter for a single element for loop
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
- Loading branch information
1 parent
9408c68
commit 63ee923
Showing
6 changed files
with
78 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Tests from for_loop.rs that don't have suggestions | ||
|
||
#[warn(clippy::single_element_loop)] | ||
fn main() { | ||
let item1 = 2; | ||
for item in &[item1] { | ||
println!("{}", item); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: do not iterate over a single element array. | ||
--> $DIR/single_element_loop.rs:6:18 | ||
| | ||
LL | for item in &[item1] { | ||
| ^^^^^^^ | ||
| | ||
= note: `-D clippy::single-element-loop` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
|