-
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
internal: Fix Clippy warnings and replace some if let
s with match
#10440
Conversation
`clippy::semicolon_if_nothing_returned`
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 changes look good to me.
Though I am personally not a fan of "Replace if let Some(_) = foo
with if let foo.is_some()
", I prefer pattern matches. Then again my preference doesn't align with our style guide in some ways anyways which I assume this might apply to as well(would be a good addition to it at least)
Will wait for another opinion before merging.
To ensure the semicolon changes remain in future, would it be good to add a check just for that lint to CI? Edit: one way this could be done is by adding a test that checks the exit code of |
ec05308
to
9583dd5
Compare
Sorry for the force push, just noticed I wrote |
I feel like that might become very annoying(wish rustfmt would just fix that since it's a change that wouldn't change semantics anyways). |
Hmm, good point. I too wish rustfmt would handle adding semicolons in these places automatically. Doing this kind of formatting requires type information, so I can definitely see why it hasn’t been implemented. Is there any point in making semicolons consistent now if they’ll just regress over time? |
Right that does require type info... I mean it doesn't hurt making these consistent every now and then if its just running a clippy fix. At least its better than having these accumulate more and more I feel like. |
Unfortunately fixing semicolons is not something done by |
Oh that's a shame, sounds like something that could have a simple fix to it. I'll go ahead and merge this now before this might run into merge conflicts as this applies none of the weird clippy lints. |
if let
s with match
if let
s with match
I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both rust-lang/clippy#5537 and rust-analyzer/rowan#57 (comment)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and
if let
vsmatch
commits provide comparatively little benefit when compared to the ensuing churn.I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.
Sidenote: I should really have asked about this on Zulip before going through all 1,555
if let
s in the codebase to decide which ones definitely look better asmatch
:P