Skip to content

Commit fd51cc6

Browse files
committed
Use DefKind to check for generator.
1 parent 8fa7bdf commit fd51cc6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_mir_transform/src/const_prop_lint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
4949
}
5050

5151
let def_id = body.source.def_id().expect_local();
52-
let is_fn_like = tcx.def_kind(def_id).is_fn_like();
53-
let is_assoc_const = tcx.def_kind(def_id) == DefKind::AssocConst;
52+
let def_kind = tcx.def_kind(def_id);
53+
let is_fn_like = def_kind.is_fn_like();
54+
let is_assoc_const = def_kind == DefKind::AssocConst;
5455

5556
// Only run const prop on functions, methods, closures and associated constants
5657
if !is_fn_like && !is_assoc_const {
@@ -59,10 +60,9 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
5960
return;
6061
}
6162

62-
let is_generator = tcx.type_of(def_id.to_def_id()).instantiate_identity().is_generator();
6363
// FIXME(welseywiser) const prop doesn't work on generators because of query cycles
6464
// computing their layout.
65-
if is_generator {
65+
if let DefKind::Generator = def_kind {
6666
trace!("ConstProp skipped for generator {:?}", def_id);
6767
return;
6868
}

0 commit comments

Comments
 (0)