-
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
New lint for all/any after mapping to bool #8396
New lint for all/any after mapping to bool #8396
Conversation
r? @flip1995 (rust-highfive has picked a reviewer for you, use r? to override) |
@rustbot label -S-waiting-on-review |
@rustbot label +S-waiting-on-review I am not a native English speaker so could you please improve the documentation? |
Couldn't it ignore the count of the So from your tests, To put it another way: wouldn't it make sense that it only depends on the count of the transformer? With that, I have a few concerns that should also be tested:
Yes sure! |
☔ The latest upstream changes (presumably #8400) made this pull request unmergeable. Please resolve the merge conflicts. |
3f573b9
to
a09008d
Compare
I see rebasing has gone horribly wrong here. In cases like this |
52489f7
to
a09008d
Compare
Thanks! |
3f573b9
to
d33763b
Compare
For example, it is better not to lint the following code (from Clippy source). If the size of the term of a body of closures can be measured, using the size as heuristics may be good. .map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local()))
.any(|imp| has_unsafe(cx, imp));
Do you mean that it is not good to have more than one lint triggered at the same time? |
On the same part of code, this should be avoided, because it can lead to confusing suggestions. If 2 lints trigger on the same expression with different suggestions on how to fix it, it is more confusing than helpful. This can be prevented by checking if another lint triggered. This is down by returning Note: if applying one lint suggestion, results in another lint triggering when re-running Clippy, it is not that bad. |
☔ The latest upstream changes (presumably #8489) made this pull request unmergeable. Please resolve the merge conflicts. |
0a4dc7b
to
2c16df1
Compare
@flip1995 @rustbot label -S-waiting-on-author +S-waiting-on-review |
☔ The latest upstream changes (presumably #8534) made this pull request unmergeable. Please resolve the merge conflicts. |
@tamaroning I'm going to close this PR, if you want to continue development on it, I'd advice completely re-starting on another branch with the new PR process. Although, if you really want to just develop further in this (very outdated) branch, feel free to re-open it. |
fixes #7339
This new lint [map_then_identity_transformer] finds
_.map(_).<transformer>(_)
where themap
is collapsible into<transformer>
. (<transformer>
is any ofall
,any
,,find
find_map
,flat_map
,filter_map
,fold
,position
,position
, andmap
.)If the transformer is the form of
<transformer>(Closure)
, this lint decides if or not themap
is collapsible by checking if a paramters is referenced one time in the body of theClosure
.changelog:
3/6
.map().find()
bacause onlyfind
takes a closure like|&x| x
.map(Closure).<transformer>(Closure)
.map(Path).<transformer>(Closure)
.map(Closure or Path).<transformer>(Path)