Skip to content

Commit 9dd18a3

Browse files
Move closure check upwards
1 parent 87d859a commit 9dd18a3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/librustc_mir_build/lints.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &ReadOnlyBodyAndCache<'_, 'tcx>, d
1313
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
1414

1515
if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(hir_id)) {
16-
check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), body, def_id);
16+
if let FnKind::Closure(_) = fn_like_node.kind() {
17+
// closures can't recur, so they don't matter.
18+
return;
19+
}
20+
21+
check_fn_for_unconditional_recursion(tcx, body, def_id);
1722
}
1823
}
1924

2025
fn check_fn_for_unconditional_recursion<'tcx>(
2126
tcx: TyCtxt<'tcx>,
22-
fn_kind: FnKind<'_>,
2327
body: &ReadOnlyBodyAndCache<'_, 'tcx>,
2428
def_id: DefId,
2529
) {
26-
if let FnKind::Closure(_) = fn_kind {
27-
// closures can't recur, so they don't matter.
28-
return;
29-
}
30-
3130
let self_calls = find_blocks_calling_self(tcx, &body, def_id);
3231
let mut results = IndexVec::from_elem_n(vec![], body.basic_blocks().len());
3332
let mut queue: VecDeque<_> = self_calls.iter().collect();

0 commit comments

Comments
 (0)