-
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
adding condition for map_clone message #8688
adding condition for map_clone message #8688
Conversation
if msrv < 1.36, the message tells , but the suggestion is
r? @llogiq (rust-highfive has picked a reviewer for you, use r? to override) |
clippy_lints/src/map_clone.rs
Outdated
@@ -143,7 +143,7 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) { | |||
impl MapClone { | |||
fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) { | |||
let mut applicability = Applicability::MachineApplicable; | |||
let message = if is_copy { | |||
let message = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) { |
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.
nits: Since it's the same as sugg_method
, so it would be better to put them into one like this:
let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
("you are using an explicit closure for copying elements", "copied")
} else {
("you are using an explicit closure for cloning elements", "cloned")
};
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.
This way is more cooler.
Thank you!
@bors r+ Thanks! |
📌 Commit 40224f4 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This PR fixes the message about
map_clone
.if msrv >= 1.36, the message is correct.
but, if msrv < 1.36, the suggestion is
cloned
, but the message iscopying
.I think the separation of messages will make it more user-friendly.
thank you in advance.
changelog: Fixed a message in map_clone.