Skip to content

Commit 735950c

Browse files
notriddleblyxyas
andcommitted
Fix style nits
Co-authored-by: Alejandra González <[email protected]>
1 parent 6d713ce commit 735950c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clippy_lints/src/matches/manual_unwrap_or.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ fn get_none<'tcx>(cx: &LateContext<'_>, arm: &Arm<'tcx>, allow_wildcard: bool) -
4848
&& cx.tcx.lang_items().get(LangItem::ResultErr) == Some(def_id)
4949
{
5050
Some(arm.body)
51-
} else if let (PatKind::Wild, true) = (arm.pat.kind, allow_wildcard) {
51+
} else if let PatKind::Wild = arm.pat.kind
52+
&& allow_wildcard
53+
{
5254
// We consider that the `Some` check will filter it out if it's not right.
5355
Some(arm.body)
5456
} else {
@@ -65,8 +67,8 @@ fn get_some_and_none_bodies<'tcx>(
6567
&& let Some(body_none) = get_none(cx, arm2, true)
6668
{
6769
Some(((arm1.body, binding_id), body_none))
68-
} else if let Some(binding_id) = get_some(cx, arm2.pat)
69-
&& let Some(body_none) = get_none(cx, arm1, false)
70+
} else if let Some(body_none) = get_none(cx, arm1, false)
71+
&& let Some(binding_id) = get_some(cx, arm2.pat)
7072
{
7173
Some(((arm2.body, binding_id), body_none))
7274
} else {

tests/ui/manual_unwrap_or_default.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ fn main() {
6666
};
6767

6868
// edge case
69+
// because the `Some(bizarro)` pattern is not actually reachable,
70+
// changing this match to `unwrap_or_default` would have side effects
6971
let bizarro = Some(String::new());
7072
match bizarro {
7173
_ => String::new(),

0 commit comments

Comments
 (0)