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

search_is_some incorrect text #11681

Closed
xNxExOx opened this issue Oct 18, 2023 · 4 comments · Fixed by #12140
Closed

search_is_some incorrect text #11681

xNxExOx opened this issue Oct 18, 2023 · 4 comments · Fixed by #12140
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@xNxExOx
Copy link

xNxExOx commented Oct 18, 2023

Summary

Help suggestion is wrong.
It say to use any instead of any, but the code does not contains any.

Reproducer

I tried this code:

 let _ = [1, 2, 3].iter().find(|x| **x == 3).is_some();

I expected to see this happen:
I did not really think about using any, so I did not expect an warning.

Instead, this happened:

warning: called `is_some()` after searching an `Iterator` with `find`
 --> src/main.rs:4:30
  |
4 |     let _ = [1, 2, 3].iter().find(|x| **x == 3).is_some();
  |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x == 3)`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
  = note: `#[warn(clippy::search_is_some)]` on by default

Version

rustc 1.72.0 (5680fa18f 2023-08-23)
binary: rustc
commit-hash: 5680fa18feaa87f3ff04063800aec256c3d4b4be
commit-date: 2023-08-23
host: x86_64-pc-windows-msvc
release: 1.72.0
LLVM version: 16.0.5

Additional Labels

No response

@xNxExOx xNxExOx added the C-bug Category: Clippy is not doing the correct thing label Oct 18, 2023
@llogiq
Copy link
Contributor

llogiq commented Oct 29, 2023

The suggestion is correct. You missed the colon, which means the following is how to use any instead.

@xNxExOx
Copy link
Author

xNxExOx commented Oct 29, 2023

I do not know, if the sentence is technically correct in UK English, or US English, or AU English, or any other subset of English, but to me it is really confusing. Something like help: consider using: `any(|x| *x == 3)` instead would make much more sense.

Even just help: use `any()` would be less confusing that the current wording.

@GuillaumeGomez
Copy link
Member

We use consider using in a few places, so I think we should here as well. Sending a fix.

@GuillaumeGomez
Copy link
Member

I opened #12140.

@bors bors closed this as completed in a71211d Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants