-
Notifications
You must be signed in to change notification settings - Fork 1.7k
handle another type of collapsible if-statement #15027
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
Conversation
This comment has been minimized.
This comment has been minimized.
I'll take this one as I have already #14906 on my plate. |
clippy
to handle another type of collapsible if-statement
This comment has been minimized.
This comment has been minimized.
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.
The current state of commits (merges, followed by revert of merges) makes it harder to review. Can you please cleanup the commits and have only one commit on top of master
?
Some notes about the current code:
- You should run
cargo dev dogfood
and fix the issues before requesting a review, otherwise the CI will be red. In particular,if
statements can be collapsed, which is kinda ironical given that the changes are in "collapsible_if.rs". - You can inline the
spanless_eq
variable at the place of its only use. - Use
Sugg::hir_with_applicability()
in order to get a proper applicability to use in suggestion. Here, you useMachineApplicable
in any case, even ifSugg::hir()
used the placeholders. - What does it mean for
cond_sugg
to contain the empty string as a suggestion? You should not need to make it mutable, write it aslet cond_sugg = if …
. Mutability complicates the code, as you have to check every code path to make sure the variable isn't modified. - The
check_collapsible_if_nested_if_else()
function should be pushed down later in the file, it is surprising to see it right after the lint declaration. - How will the code behave in the presence of comments between the two
if
? It should probably not lint if comments are present and would be removed by the rewrite. Maybe thelint_commented_code
config option could be used if we can find a sensible way to preserve comments. - Instead of dealing with
DropTemps
, you should look athigher::If
and see if it could be used instead to deconstruct theif
statements.
Sorry for the inconvenience and thank you for the advice, I'll work on implementing your suggestions. |
@samueltardieu With regard to your last suggestion, I'm not sure if I can implement it as I'm already trying to handle cases where |
Is there any case where |
@samueltardieu I see, thanks for letting me know about that. Based on my current understanding, Now that I think about it, I should be able to implement the last suggestion. |
fixes #812
changelog: [
collapsible_if
]: handle another type of collapsible if-statement