-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Extend map_clone
lint to also work on non-explicit closures
#12104
Conversation
Would it then make sense to also change the message because Perhaps something like "manually implementing |
Sounds good to me! Just realized that I also left some code I was working on for another update... I also need to fix dogfood which found issues thanks to this update. |
5ea0e80
to
2dd3ac9
Compare
2dd3ac9
to
af35d37
Compare
Fixed the CI failures. :) |
// FIXME: It would be better to infer the type to check if it's copyable or not | ||
// to suggest to use `.copied()` instead of `.cloned()` where applicable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would getting the iterator type from the map(_)
and then extracting the Item
type work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a try.
Looks good to me. Any further extensions can be a follow up PR. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Handle "calls" inside the closure as well in `map_clone` lint Follow-up of #12104. I just realized that I didn't handle the case where the `clone` method was made as a call and not a method call. r? `@llogiq` changelog: Handle "calls" inside the closure as well in `map_clone` lint
Fix suggestion for `map_clone` lint on types implementing `Copy` Follow-up of #12104. It was missing this check to suggest the correct method. r? `@llogiq` changelog: Fix suggestion for `map_clone` lint on types implementing `Copy`
I found it weird that this case was not handled by the current line so I added it. The only thing is that I don't see an obvious way to infer the current type to determine if it's copyable or not, so for now I always suggest
cloned
and I added a FIXME.r? @llogiq
changelog: Extend
map_clone
lint to also work on non-explicit closures