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
[manual_unwrap_or_default
]: Check for Default trait implementation in initial condition when linting and use IfLetOrMatch
#12610
[manual_unwrap_or_default
]: Check for Default trait implementation in initial condition when linting and use IfLetOrMatch
#12610
Conversation
The implementation looks fine to me but I just have one nit suggestion. It's not in your modifications but these two lines: if let ExprKind::If(cond, if_block, Some(else_expr)) = expr.kind
&& let ExprKind::Let(let_) = cond.kind could be replaced with Oh, btw, if conflicts ever come up, the easiest way would be doing a And even if you messed up, you can always do a hard reset then do a force push. I learn that from the hard way here, lol 🤣 |
I'll try and make the change you suggested.
About this, even the original code won't trigger in a if let ExprKind::If(cond, if_block, Some(else_expr)) = expr.kind so we're essentially just checking |
Yes, but afaik it could be a de-sugared while loop, the Oh wait, there's a |
I'll see what I can do with it. That would greatly simplify the code. |
d740bf6
to
ac18c24
Compare
I tried to make the code as readable as possible and added comments. Apologies if it looks like spaghetti code. |
manual_unwrap_or_default
]manual_unwrap_or_default
]: Check for Default trait implementation in initial condition when linting and use IfLetOrMatch
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.
Nice work!
Thank you! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #12564
changelog: Fix [
manual_unwrap_or_default
] false positive when initialmatch
/if let
condition doesn't implementDefault
but the return type does.