Skip to content

Commit 241eae7

Browse files
committed
Monomorphize ConstantKind::Unevaluated in mir_operand_get_const_val
1 parent 5ed4377 commit 241eae7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/constant.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,13 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
459459
operand: &Operand<'tcx>,
460460
) -> Option<ConstValue<'tcx>> {
461461
match operand {
462-
Operand::Constant(const_) => match const_.literal {
463-
ConstantKind::Ty(const_) => fx
464-
.monomorphize(const_)
465-
.eval_for_mir(fx.tcx, ParamEnv::reveal_all())
466-
.try_to_value(fx.tcx),
462+
Operand::Constant(const_) => match fx.monomorphize(const_.literal) {
463+
ConstantKind::Ty(const_) => Some(
464+
const_.eval_for_mir(fx.tcx, ParamEnv::reveal_all()).try_to_value(fx.tcx).unwrap(),
465+
),
467466
ConstantKind::Val(val, _) => Some(val),
468467
ConstantKind::Unevaluated(uv, _) => {
469-
fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), uv, None).ok()
468+
Some(fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), uv, None).unwrap())
470469
}
471470
},
472471
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored

0 commit comments

Comments
 (0)