Skip to content
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

Fix #4033 search_is_some #4049

Merged
merged 5 commits into from
May 2, 2019
Merged

Conversation

airt
Copy link
Contributor

@airt airt commented Apr 30, 2019

Fixes #4033.

Suggest any(|x| ..) instead of any(|&x| ..) for find(|&x| ..).is_some() (Lint search_is_some)

FnDecl of find:

fn find<P>(&mut self, mut p: P) -> Option<Self::Item> where
    P: FnMut(&Self::Item) -> bool

FnDecl of any:

fn any<F>(&mut self, mut f: F) -> bool where
    F: FnMut(Self::Item) -> bool

If match on |&_| in closure of find, only use |_| in the suggestion.

PS. It's the first time that I have used the hir API, please correct me if there is any mistake 😺

@flip1995
Copy link
Member

Also rustfmt. Everything else LGTM

@flip1995
Copy link
Member

flip1995 commented May 2, 2019

Thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented May 2, 2019

📌 Commit d063516 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented May 2, 2019

⌛ Testing commit d063516 with merge 8151a17...

bors added a commit that referenced this pull request May 2, 2019
Fix #4033 search_is_some

Fixes #4033.

Suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()` (Lint [search_is_some](https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some))

FnDecl of `find`:

```rust
fn find<P>(&mut self, mut p: P) -> Option<Self::Item> where
    P: FnMut(&Self::Item) -> bool
```

FnDecl of `any`:

```rust
fn any<F>(&mut self, mut f: F) -> bool where
    F: FnMut(Self::Item) -> bool
```

If match on `|&_|` in closure of `find`, only use `|_|` in the suggestion.

PS. It's the first time that I have used the `hir` API, please correct me if there is any mistake 😺
@bors
Copy link
Collaborator

bors commented May 2, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: flip1995
Pushing 8151a17 to master...

@bors bors merged commit d063516 into rust-lang:master May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

search_is_some fixit hint suggests invalid code
3 participants