Skip to content

Wrong suggestion in search_is_some lint #4453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flip1995 opened this issue Aug 26, 2019 · 2 comments · Fixed by #4454
Closed

Wrong suggestion in search_is_some lint #4453

flip1995 opened this issue Aug 26, 2019 · 2 comments · Fixed by #4454
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@flip1995
Copy link
Member

flip1995 commented Aug 26, 2019

It's pretty much the same as #4033. The closure argument of any needs one dereference less than the closure argument of find.

fn main() {
    let vec = vec![1];
    let _ = vec.iter().find(|x| **x == 0).is_some();
    // let _ = vec.iter().any(|x| **x == 0); // <- this is suggested
    let _ = vec.iter().any(|x| *x == 0); // <- this should be suggested
}

Playground

Originally posted by @BO41 in #4436 (comment)

@flip1995 flip1995 added L-suggestion Lint: Improving, adding or fixing lint suggestions good first issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Aug 26, 2019
@flip1995
Copy link
Member Author

This suggestion could also be made auto applicable.

@YpeKingma
Copy link

This code still gives the wrong suggestion when clippied:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=42845deb52e66a5fb4e689782d2cd5f0

Shall I open another issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants