-
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.
Regression test for explicit_iter_loop
- Loading branch information
Showing
2 changed files
with
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Tracking issue: #3913 | ||
#![deny(clippy::explicit_iter_loop)] | ||
|
||
fn main() { | ||
let vec = vec![1]; | ||
for _v in vec.iter() {} //~ ERROR change to `&vec` | ||
} |
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,14 @@ | ||
error: it is more concise to loop over references to containers instead of using explicit iteration methods | ||
--> $DIR/explicit_iter_loop_no_sugg.rs:6:15 | ||
| | ||
LL | for _v in vec.iter() {} //~ ERROR change to `&vec` | ||
| ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | ||
| | ||
note: lint level defined here | ||
--> $DIR/explicit_iter_loop_no_sugg.rs:2:9 | ||
| | ||
LL | #![deny(clippy::explicit_iter_loop)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|