[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.kindcould 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.kindso 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
|
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 letcondition doesn't implementDefaultbut the return type does.