Skip to content

Commit 39b316d

Browse files
committed
an empty match diverges
1 parent 6801189 commit 39b316d

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

clippy_lints/src/loops/never_loop.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,11 @@ fn never_loop_expr<'tcx>(
194194
},
195195
ExprKind::Match(e, arms, _) => {
196196
let e = never_loop_expr(cx, e, local_labels, main_loop_id);
197-
if arms.is_empty() {
198-
e
199-
} else {
200-
combine_seq(e, || {
201-
never_loop_expr_branch(cx, &mut arms.iter().map(|a| a.body), local_labels, main_loop_id)
197+
combine_seq(e, || {
198+
arms.iter().fold(NeverLoopResult::Diverging, |a, b| {
199+
combine_branches(a, never_loop_expr(cx, b.body, local_labels, main_loop_id))
202200
})
203-
}
201+
})
204202
},
205203
ExprKind::Block(b, l) => {
206204
if l.is_some() {
@@ -276,17 +274,6 @@ fn never_loop_expr_all<'tcx, T: Iterator<Item = &'tcx Expr<'tcx>>>(
276274
combine_seq_many(es.map(|e| never_loop_expr(cx, e, local_labels, main_loop_id)))
277275
}
278276

279-
fn never_loop_expr_branch<'tcx, T: Iterator<Item = &'tcx Expr<'tcx>>>(
280-
cx: &LateContext<'tcx>,
281-
e: &mut T,
282-
local_labels: &mut Vec<(HirId, bool)>,
283-
main_loop_id: HirId,
284-
) -> NeverLoopResult {
285-
e.fold(NeverLoopResult::Diverging, |a, b| {
286-
combine_branches(a, never_loop_expr(cx, b, local_labels, main_loop_id))
287-
})
288-
}
289-
290277
fn for_to_if_let_sugg(cx: &LateContext<'_>, iterator: &Expr<'_>, pat: &Pat<'_>) -> String {
291278
let pat_snippet = snippet(cx, pat.span, "_");
292279
let iter_snippet = make_iterator_snippet(cx, iterator, &mut Applicability::Unspecified);

0 commit comments

Comments
 (0)