Skip to content

Commit bf5170a

Browse files
committed
match arm pats aren't Optional anymore
1 parent 83e2b3d commit bf5170a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

clippy_lints/src/matches/match_like_matches.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ pub(super) fn check_match<'tcx>(
6767
) -> bool {
6868
let mut arms = arms
6969
.iter()
70-
.map(|arm| (cx.tcx.hir_attrs(arm.hir_id), Some(arm.pat), arm.body, arm.guard));
70+
.map(|arm| (cx.tcx.hir_attrs(arm.hir_id), arm.pat, arm.body, arm.guard));
7171
if !span_contains_comment(cx.sess().source_map(), e.span)
7272
&& arms.len() >= 2
7373
&& cx.typeck_results().expr_ty(e).is_bool()
74-
&& let Some((_, last_pat_opt, last_expr, _)) = arms.next_back()
74+
&& let Some((_, last_pat, last_expr, _)) = arms.next_back()
7575
&& let arms_without_last = arms.clone()
7676
&& let Some((first_attrs, _, first_expr, first_guard)) = arms.next()
7777
&& let Some(b0) = find_bool_lit(first_expr)
@@ -81,17 +81,13 @@ pub(super) fn check_match<'tcx>(
8181
&& first_attrs.is_empty()
8282
&& arms.all(|(attrs, _, expr, guard)| attrs.is_empty() && guard.is_none() && find_bool_lit(expr) == Some(b0))
8383
{
84-
if let Some(last_pat) = last_pat_opt
85-
&& !is_wild(last_pat)
86-
{
84+
if !is_wild(last_pat) {
8785
return false;
8886
}
8987

9088
for arm in arms_without_last.clone() {
91-
if let Some(pat) = arm.1
92-
&& !is_lint_allowed(cx, REDUNDANT_PATTERN_MATCHING, pat.hir_id)
93-
&& is_some_wild(pat.kind)
94-
{
89+
let pat = arm.1;
90+
if !is_lint_allowed(cx, REDUNDANT_PATTERN_MATCHING, pat.hir_id) && is_some_wild(pat.kind) {
9591
return false;
9692
}
9793
}
@@ -102,9 +98,9 @@ pub(super) fn check_match<'tcx>(
10298
let pat = {
10399
use itertools::Itertools as _;
104100
arms_without_last
105-
.filter_map(|arm| {
106-
let pat_span = arm.1?.span;
107-
Some(snippet_with_applicability(cx, pat_span, "..", &mut applicability))
101+
.map(|arm| {
102+
let pat_span = arm.1.span;
103+
snippet_with_applicability(cx, pat_span, "..", &mut applicability)
108104
})
109105
.join(" | ")
110106
};

0 commit comments

Comments
 (0)