Skip to content

Commit 9096b3e

Browse files
committed
implement valtrees as the type-system representation for constant values
1 parent ce2b3a9 commit 9096b3e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/constant.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(crate) fn codegen_constant<'tcx>(
127127
ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
128128
};
129129
let const_val = match const_.kind() {
130-
ConstKind::Value(const_val) => const_val,
130+
ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
131131
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
132132
if fx.tcx.is_static(def.did) =>
133133
{
@@ -468,9 +468,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
468468
) -> Option<ConstValue<'tcx>> {
469469
match operand {
470470
Operand::Constant(const_) => match const_.literal {
471-
ConstantKind::Ty(const_) => {
472-
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).kind().try_to_value()
473-
}
471+
ConstantKind::Ty(const_) => fx
472+
.monomorphize(const_)
473+
.eval_for_mir(fx.tcx, ParamEnv::reveal_all())
474+
.try_to_value(fx.tcx),
474475
ConstantKind::Val(val, _) => Some(val),
475476
},
476477
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored

0 commit comments

Comments
 (0)