Skip to content

Commit a09b7eb

Browse files
committed
Use DefKind instead of FnKind for recursion lint.
1 parent 6733bc3 commit a09b7eb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

compiler/rustc_mir_build/src/lints.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_data_structures::graph::iterate::{
22
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
33
};
4-
use rustc_hir::intravisit::FnKind;
4+
use rustc_hir::def::DefKind;
55
use rustc_middle::mir::{BasicBlock, BasicBlocks, Body, Operand, TerminatorKind};
66
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
77
use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
@@ -12,12 +12,7 @@ use std::ops::ControlFlow;
1212
pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
1313
let def_id = body.source.def_id().expect_local();
1414

15-
if let Some(fn_kind) = tcx.hir().get_by_def_id(def_id).fn_kind() {
16-
if let FnKind::Closure = fn_kind {
17-
// closures can't recur, so they don't matter.
18-
return;
19-
}
20-
15+
if let DefKind::Fn | DefKind::AssocFn = tcx.def_kind(def_id) {
2116
// If this is trait/impl method, extract the trait's substs.
2217
let trait_substs = match tcx.opt_associated_item(def_id.to_def_id()) {
2318
Some(AssocItem {

0 commit comments

Comments
 (0)