Skip to content

Commit

Permalink
manual-unwrap-or / more pr remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tnielens committed Oct 14, 2020
1 parent fc846c3 commit a8fb69f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions clippy_lints/src/manual_unwrap_or.rs
Expand Up @@ -47,7 +47,7 @@ impl LateLintPass<'_> for ManualUnwrapOr {
}
}

fn lint_option_unwrap_or_case<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
fn lint_option_unwrap_or_case<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
fn applicable_none_arm<'a>(arms: &'a [Arm<'a>]) -> Option<&'a Arm<'a>> {
if_chain! {
if arms.len() == 2;
Expand All @@ -69,8 +69,7 @@ fn lint_option_unwrap_or_case<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tc
if !utils::usage::contains_return_break_continue_macro(none_arm.body);
then {
Some(none_arm)
}
else {
} else {
None
}
}
Expand Down Expand Up @@ -102,14 +101,11 @@ fn lint_option_unwrap_or_case<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tc
"{}.{}({}{})",
scrutinee_snippet,
method,
if eager_eval { ""} else { "|| " },
if eager_eval { "" } else { "|| " },
reindented_none_body
),
Applicability::MachineApplicable,
);
true
} else {
false
}
}
}

0 comments on commit a8fb69f

Please sign in to comment.