-
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
Implement "suspicious_map" lint #4394
Conversation
clippy_lints/src/methods/mod.rs
Outdated
cx, | ||
SUSPICIOUS_MAP, | ||
expr.span, | ||
"Make sure you did not confuse `map` with `filter`.", |
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.
Someone should document the rules of rust error messages and suggestions somewhere somtimes. 😄
"Make sure you did not confuse `map` with `filter`.", | |
"make sure you did not confuse `map` with `filter`", |
IMO this should be a span_help_and_lint
:
- message: "this call to
map()
won't have an effect on the call tocount()
" - help: "make sure you did not confuse
map
withfliter
"
clippy_lints/src/methods/mod.rs
Outdated
/// let _ = (0..3).map(|x| x + 2).count(); | ||
/// ``` | ||
pub SUSPICIOUS_MAP, | ||
pedantic, |
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.
I think this could even be a style
(Using map for side effects should be rewritten) or complexity
(Using map for side effects might be confusing and can be written less complex) lint.
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.
You're right. I just thought it was too invasive at first
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.
Let's try it. If people complain, we can still move it to pedantic.
Thanks! @bors r+ |
📌 Commit 9c39c02 has been approved by |
Implement "suspicious_map" lint Resolves #4010 changelog: New lint `suspicious_map`.
☀️ Test successful - checks-travis, status-appveyor |
This lint does not seem to be checking if the Do you think this lint should take other |
Resolves #4010
changelog: New lint
suspicious_map
.