Repository navigation
Add ifs_as_logical_ops lint - #14904
Add ifs_as_logical_ops lint #14904barun511 wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
ed0c921 to
a277b18
Compare
|
Hm, it doesn't look like my rebase really worked, let me have another go... |
a277b18 to
ed0c921
Compare
|
I'll take a look at merge conflicts once I've got a review, I think |
Jarcho
left a comment
There was a problem hiding this comment.
Did a first pass over this. You'll need a late pass to avoid an annoying false positive.
ed0c921 to
5baaae2
Compare
|
Thanks for the review! I had a go at writing it with a late lint pass |
|
@rustbot ready |
Jarcho
left a comment
There was a problem hiding this comment.
First just a couple of small changes. These are a little nitpicky.
|
Thanks! Responded |
|
@rustbot ready |
Jarcho
left a comment
There was a problem hiding this comment.
Next you'll need to handle macros and fill in the docs.
e7123b6 to
bcfe2fe
Compare
|
@rustbot ready |
|
No worries! Sorry for not responding to the message above, it wasn't clear to me how far away from approval the PR was - and given that it didn't seem to get any traction after a point I didn't want to keep maintaining the PR if the work wasn't a priority. I'm happy to clean this up tomorrow |
|
Oh I still had my unanswered question about proc_macro above, but I can try and figure that out myself |
009e0c6 to
2809710
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
4b3db68 to
432d723
Compare
I'd say it looks pretty much ready to merge, after we figure out the proc-macro stuff (if you don't manage to figure it out yourself, consider asking @.Jarcho). Thanks again for all your work so far:) |
84354f9 to
121afb8
Compare
|
Regarding the question: "Why does removing the is_proc_macro check not cause the test to fail?" I investigated by doing the following:
It seems like this piece of code returns false for proc_macros, because the span of the macro usually does not have the character '{' in it. I'm not quite sure what to make of this - of course after we add the check we won't be hitting this case, but we then don't have a test case that would fail if the in_proc_macro or in_external_macro checks are removed. We could always consider taking this as a follow up/finding a more robust way of checking that there are no comments in the span |
|
(or also potentially I'm not walking the span to the context correctly)? |
|
You can practically ignore the proc macro check since you're basically already doing it when you check for comments. If you wrote the test as |
|
You might want to add |
All the original work Address all comments really fr fr
121afb8 to
3c7a831
Compare
|
Yep, I did update my global gitignore, and i've updated to no longer use proc macro check! Lmk if anything else is blocking |
There was a problem hiding this comment.
|
This lint has been nominated for inclusion. |
|
@Jarcho just pinging for re-review here! |
|
☔ The latest upstream changes (possibly #13598) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Sorry, forgot to finish the FCP... There has been one approval by @llogiq, so I'd say let's merge this after the rebase and one fix
| /// b1 && a() | ||
| /// } | ||
| /// ``` | ||
| #[clippy::version = "1.100.0"] |
There was a problem hiding this comment.
| #[clippy::version = "1.100.0"] | |
| #[clippy::version = "1.101.0"] |
View all comments
Fixes #14865 by adding the ifs_as_logical_ops lint.
Only adds the conjunctive version (transform if x else y => x && y) for now.
Please write a short comment explaining your change (or "none" for internal only changes)
changelog: [
ifs_as_logical_ops] : "Warn about cases wherex && ycould be used in place of if conditions"