-
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
Add new manual_unwrap_or_default
lint
#12440
Add new manual_unwrap_or_default
lint
#12440
Conversation
91d8ebf
to
e7155a4
Compare
Also I'm not a big fan of the lint name but couldn't find anything better. If anyone has a suggestion, it'd be very appreciated. :) |
c1863a9
to
890051a
Compare
☔ The latest upstream changes (presumably #12449) made this pull request unmergeable. Please resolve the merge conflicts. |
How about |
&& local_id == binding_id | ||
// We now check the `None` arm is calling a method equivalent to `Default::default`. | ||
&& let body_none = body_none.peel_blocks() | ||
&& let ExprKind::Call(_, &[]) = body_none.kind |
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.
Is that really needed here, when in the next line we check for defaultness?
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.
Just checked the is_default_equivalent
implementation and you're absolutely right! Even worse: this check can actually be pretty bad as it excludes some potential cases I don't cover from what I saw. Good catch!
de4d0e9
to
8878053
Compare
8878053
to
98ac5f1
Compare
Renamed and applied the suggestion. Thanks for both! :) |
match_option_and_default
lintmanual_unwrap_or_default
lint
Thank you for writing this lint! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This adds a new lint checking if a
match
or aif let
can be replaced withunwrap_or_default
.changelog: Add new [
manual_unwrap_or_default
] lint