Skip to content

Commit a8556da

Browse files
committed
Fix crash for CrateItem::kind() with constructors
Change how we classify item kind for DefKind::Ctor
1 parent 92ad4b4 commit a8556da

File tree

1 file changed

+8
-5
lines changed
  • compiler/rustc_smir/src/rustc_smir

1 file changed

+8
-5
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
99
10-
use rustc_hir::def::DefKind;
10+
use rustc_hir::def::{CtorKind, DefKind};
1111
use rustc_middle::mir;
1212
use rustc_middle::mir::interpret::AllocId;
1313
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
@@ -88,14 +88,17 @@ pub(crate) fn new_item_kind(kind: DefKind) -> ItemKind {
8888
| DefKind::Field
8989
| DefKind::LifetimeParam
9090
| DefKind::Impl { .. }
91-
| DefKind::Ctor(_, _)
9291
| DefKind::GlobalAsm => {
9392
unreachable!("Not a valid item kind: {kind:?}");
9493
}
95-
DefKind::Closure | DefKind::AssocFn | DefKind::Fn => ItemKind::Fn,
96-
DefKind::Const | DefKind::InlineConst | DefKind::AssocConst | DefKind::AnonConst => {
97-
ItemKind::Const
94+
DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure | DefKind::AssocFn | DefKind::Fn => {
95+
ItemKind::Fn
9896
}
97+
DefKind::Ctor(_, CtorKind::Const)
98+
| DefKind::Const
99+
| DefKind::InlineConst
100+
| DefKind::AssocConst
101+
| DefKind::AnonConst => ItemKind::Const,
99102
DefKind::Static(_) => ItemKind::Static,
100103
}
101104
}

0 commit comments

Comments
 (0)