Extend map_clone lint to also work on non-explicit closures#12104
Merged
bors merged 3 commits intorust-lang:masterfrom Jan 6, 2024
Merged
Extend map_clone lint to also work on non-explicit closures#12104bors merged 3 commits intorust-lang:masterfrom
map_clone lint to also work on non-explicit closures#12104bors merged 3 commits intorust-lang:masterfrom
Conversation
Contributor
|
Would it then make sense to also change the message because Perhaps something like "manually implementing |
Member
Author
|
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
Member
Author
|
Fixed the CI failures. :) |
llogiq
approved these changes
Jan 6, 2024
Comment on lines
+74
to
+75
| // 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. |
Contributor
There was a problem hiding this comment.
Would getting the iterator type from the map(_) and then extracting the Item type work here?
Contributor
|
Looks good to me. Any further extensions can be a follow up PR. @bors r+ |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
bors
added a commit
that referenced
this pull request
Jan 7, 2024
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
bors
added a commit
that referenced
this pull request
Jan 11, 2024
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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
clonedand I added a FIXME.r? @llogiq
changelog: Extend
map_clonelint to also work on non-explicit closures