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#11016 - y21:issue10029, r=blyxyas,dswij
[`filter_next`]: suggest making binding mutable if it needs to be Fixes rust-lang#10029 changelog: [`filter_next`]: suggest making binding mutable if it needs to be and adjust applicability
- Loading branch information
Showing
3 changed files
with
66 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![warn(clippy::filter_next)] | ||
|
||
fn main() { | ||
issue10029(); | ||
} | ||
|
||
pub fn issue10029() { | ||
let iter = (0..10); | ||
let _ = iter.filter(|_| true).next(); | ||
} |
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,15 @@ | ||
error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead | ||
--> $DIR/methods_unfixable.rs:9:13 | ||
| | ||
LL | let _ = iter.filter(|_| true).next(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `iter.find(|_| true)` | ||
| | ||
help: you will also need to make `iter` mutable, because `find` takes `&mut self` | ||
--> $DIR/methods_unfixable.rs:8:9 | ||
| | ||
LL | let iter = (0..10); | ||
| ^^^^ | ||
= note: `-D clippy::filter-next` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
|