Skip to content

Commit 9e6c044

Browse files
committed
Use is_fn_like instead of matching on DefKind
1 parent 1750a2f commit 9e6c044

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

compiler/rustc_mir_transform/src/abort_unwinding_calls.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::MirPass;
22
use rustc_ast::InlineAsmOptions;
3-
use rustc_hir::def::DefKind;
43
use rustc_middle::mir::*;
54
use rustc_middle::ty::layout;
65
use rustc_middle::ty::{self, TyCtxt};
@@ -31,11 +30,7 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
3130

3231
// We don't simplify the MIR of constants at this time because that
3332
// namely results in a cyclic query when we call `tcx.type_of` below.
34-
let is_function = match kind {
35-
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) => true,
36-
_ => tcx.is_closure(def_id),
37-
};
38-
if !is_function {
33+
if !kind.is_fn_like() {
3934
return;
4035
}
4136

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rustc_hir::def::DefKind;
21
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
32
use rustc_middle::mir::*;
43
use rustc_middle::ty::layout;
@@ -44,11 +43,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
4443
// Only perform check on functions because constants cannot call FFI functions.
4544
let def_id = local_def_id.to_def_id();
4645
let kind = tcx.def_kind(def_id);
47-
let is_function = match kind {
48-
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) => true,
49-
_ => tcx.is_closure(def_id),
50-
};
51-
if !is_function {
46+
if !kind.is_fn_like() {
5247
return false;
5348
}
5449

0 commit comments

Comments
 (0)