-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Dereference one less on search_is_some and make it auto-fixable #4454
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
Conversation
@flip1995 do you think this is enough, or is some logic required? I can make it auto fixable once everything else works 😉 How can I run doc tests? |
I think you'll first have to change to the |
I though this would be easier and the code better to understand. But it seems that I am not capable of fixing the issue 😢 |
Your not really far from the goal, and I'm happy to support you to achieve it!
For test cases, see Playground |
Thanks. That worked 😃 |
@flip1995 thank you for the help 👍 Are you sure I need |
Huh, I'm pretty sure that you need It should find a match for |
it seems like the lint isn't very exact. This causes rust-fix to replace everything with just
Or did I do something wrong? |
Rustfix always replaces the span you specify with the suggested code. You have to build the span by hand, since it does not exist in the way you need it. This shouldn't be a problem though. Just search in the |
so I should be able to replace |
No, because the You only want to replace the I just looked up how to get this span, and saw, that it is not that easy (and not really easy to explain the changes that need to be made). So I decided to write a patch for you, that simplifies this. (I'll notify you once it's ready) While looking into this, I found, that there already exists a function to get the name of the closure arg: rust-clippy/clippy_lints/src/utils/mod.rs Lines 916 to 922 in 949b347
You can just use this. |
Here's the patch: https://github.com/flip1995/rust-clippy/commits/method_calls_spans You can look at the second to last commit on the branch on how to use the method spans. Just |
☔ The latest upstream changes (presumably #4462) made this pull request unmergeable. Please resolve the merge conflicts. |
almost worked |
☔ The latest upstream changes (presumably #4408) made this pull request unmergeable. Please resolve the merge conflicts. |
Sorry about the merge conflict, let me know if I can help resolving it =) |
That was my fault in 6035b65, so I'd also resolve it for you, if need be. |
Done 👍 |
Could you add a test case where let _ = vec.iter().find(|x| **x == 0).is_some(); |
Ok one last change and a run of |
Thanks! @bors r+ |
📌 Commit 64cd9e4 has been approved by |
Dereference one less on search_is_some and make it auto-fixable Fixes #4453 changelog: none
☀️ Test successful - checks-travis, status-appveyor |
Fixes #4453
changelog: none