an empty match diverges
This commit is contained in:
parent
68011893d8
commit
39b316db61
@ -194,13 +194,11 @@ fn never_loop_expr<'tcx>(
|
|||||||
},
|
},
|
||||||
ExprKind::Match(e, arms, _) => {
|
ExprKind::Match(e, arms, _) => {
|
||||||
let e = never_loop_expr(cx, e, local_labels, main_loop_id);
|
let e = never_loop_expr(cx, e, local_labels, main_loop_id);
|
||||||
if arms.is_empty() {
|
|
||||||
e
|
|
||||||
} else {
|
|
||||||
combine_seq(e, || {
|
combine_seq(e, || {
|
||||||
never_loop_expr_branch(cx, &mut arms.iter().map(|a| a.body), local_labels, main_loop_id)
|
arms.iter().fold(NeverLoopResult::Diverging, |a, b| {
|
||||||
|
combine_branches(a, never_loop_expr(cx, b.body, local_labels, main_loop_id))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ExprKind::Block(b, l) => {
|
ExprKind::Block(b, l) => {
|
||||||
if l.is_some() {
|
if l.is_some() {
|
||||||
@ -276,17 +274,6 @@ fn never_loop_expr_all<'tcx, T: Iterator<Item = &'tcx Expr<'tcx>>>(
|
|||||||
combine_seq_many(es.map(|e| never_loop_expr(cx, e, local_labels, main_loop_id)))
|
combine_seq_many(es.map(|e| never_loop_expr(cx, e, local_labels, main_loop_id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn never_loop_expr_branch<'tcx, T: Iterator<Item = &'tcx Expr<'tcx>>>(
|
|
||||||
cx: &LateContext<'tcx>,
|
|
||||||
e: &mut T,
|
|
||||||
local_labels: &mut Vec<(HirId, bool)>,
|
|
||||||
main_loop_id: HirId,
|
|
||||||
) -> NeverLoopResult {
|
|
||||||
e.fold(NeverLoopResult::Diverging, |a, b| {
|
|
||||||
combine_branches(a, never_loop_expr(cx, b, local_labels, main_loop_id))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn for_to_if_let_sugg(cx: &LateContext<'_>, iterator: &Expr<'_>, pat: &Pat<'_>) -> String {
|
fn for_to_if_let_sugg(cx: &LateContext<'_>, iterator: &Expr<'_>, pat: &Pat<'_>) -> String {
|
||||||
let pat_snippet = snippet(cx, pat.span, "_");
|
let pat_snippet = snippet(cx, pat.span, "_");
|
||||||
let iter_snippet = make_iterator_snippet(cx, iterator, &mut Applicability::Unspecified);
|
let iter_snippet = make_iterator_snippet(cx, iterator, &mut Applicability::Unspecified);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user