forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 rust-lang#5793 - warner:5783-nth-zero-next, r=flip1995
improve advice in iter_nth_zero fixes rust-lang#5783 *Please keep the line below* changelog: For iter_nth_zero, the "use .next()" replacement advice is on the last line of the code snippet, where it is vulnerable to truncation. Display that advice at the beginning instead.
- Loading branch information
Showing
2 changed files
with
8 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
error: called `.nth(0)` on a `std::iter::Iterator` | ||
error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent | ||
--> $DIR/iter_nth_zero.rs:20:14 | ||
| | ||
LL | let _x = s.iter().nth(0); | ||
| ^^^^^^^^^^^^^^^ help: try calling: `s.iter().next()` | ||
| ^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `s.iter().next()` | ||
| | ||
= note: `-D clippy::iter-nth-zero` implied by `-D warnings` | ||
|
||
error: called `.nth(0)` on a `std::iter::Iterator` | ||
error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent | ||
--> $DIR/iter_nth_zero.rs:25:14 | ||
| | ||
LL | let _y = iter.nth(0); | ||
| ^^^^^^^^^^^ help: try calling: `iter.next()` | ||
| ^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter.next()` | ||
|
||
error: called `.nth(0)` on a `std::iter::Iterator` | ||
error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent | ||
--> $DIR/iter_nth_zero.rs:30:22 | ||
| | ||
LL | let _unwrapped = iter2.nth(0).unwrap(); | ||
| ^^^^^^^^^^^^ help: try calling: `iter2.next()` | ||
| ^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter2.next()` | ||
|
||
error: aborting due to 3 previous errors | ||
|