about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/constant.rs
diff options
context:
space:
mode:
authorb-naber <bn263@gmx.de>2022-02-16 10:56:01 +0100
committerb-naber <bn263@gmx.de>2022-06-14 16:07:11 +0200
commit705d818bd52a6324d5e7693cc4306457395eebc8 (patch)
treef5363e1a8b0426bc961970028c23670869e344fb /compiler/rustc_codegen_cranelift/src/constant.rs
parentedab34ab2abbafc16a78daedf71dbacd2eb0b7bf (diff)
downloadrust-705d818bd52a6324d5e7693cc4306457395eebc8.tar.gz
rust-705d818bd52a6324d5e7693cc4306457395eebc8.zip
implement valtrees as the type-system representation for constant values
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/constant.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/src/constant.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs
index 3d14a0eca52..ef72e6efb94 100644
--- a/compiler/rustc_codegen_cranelift/src/constant.rs
+++ b/compiler/rustc_codegen_cranelift/src/constant.rs
@@ -127,7 +127,7 @@ pub(crate) fn codegen_constant<'tcx>(
         ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
     };
     let const_val = match const_.kind() {
-        ConstKind::Value(const_val) => const_val,
+        ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
         ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
             if fx.tcx.is_static(def.did) =>
         {
@@ -468,9 +468,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
 ) -> Option<ConstValue<'tcx>> {
     match operand {
         Operand::Constant(const_) => match const_.literal {
-            ConstantKind::Ty(const_) => {
-                fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).kind().try_to_value()
-            }
+            ConstantKind::Ty(const_) => fx
+                .monomorphize(const_)
+                .eval_for_mir(fx.tcx, ParamEnv::reveal_all())
+                .try_to_value(fx.tcx),
             ConstantKind::Val(val, _) => Some(val),
         },
         // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored