about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift
diff options
context:
space:
mode:
authorb-naber <bn263@gmx.de>2022-06-27 16:32:47 +0200
committerb-naber <bn263@gmx.de>2022-09-13 17:40:59 +0200
commita4bbb8db5c4c702265b8afcc1313684a127ddd6a (patch)
treef1643aa200cd35761c02faf68189ec86276fb0d9 /compiler/rustc_codegen_cranelift
parent7098c181f8447810fadb1776d3ffa3cdc93ce402 (diff)
downloadrust-a4bbb8db5c4c702265b8afcc1313684a127ddd6a.tar.gz
rust-a4bbb8db5c4c702265b8afcc1313684a127ddd6a.zip
use ty::Unevaluated<'tcx, ()> in type system
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r--compiler/rustc_codegen_cranelift/src/constant.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs
index 0305341da78..7bf578b6a4e 100644
--- a/compiler/rustc_codegen_cranelift/src/constant.rs
+++ b/compiler/rustc_codegen_cranelift/src/constant.rs
@@ -124,11 +124,7 @@ pub(crate) fn codegen_constant<'tcx>(
 ) -> CValue<'tcx> {
     let const_ = match fx.monomorphize(constant.literal) {
         ConstantKind::Ty(ct) => ct,
-        ConstantKind::Val(val, ty) => return codegen_const_value(fx, val, ty),
-    };
-    let const_val = match const_.kind() {
-        ConstKind::Value(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
-        ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
+        ConstantKind::Unevaluated(mir::Unevaluated { def, substs, promoted })
             if fx.tcx.is_static(def.did) =>
         {
             assert!(substs.is_empty());
@@ -136,7 +132,7 @@ pub(crate) fn codegen_constant<'tcx>(
 
             return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty())).to_cvalue(fx);
         }
-        ConstKind::Unevaluated(unevaluated) => {
+        ConstantKind::Unevaluated(unevaluated) => {
             match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
                 Ok(const_val) => const_val,
                 Err(_) => {
@@ -144,6 +140,17 @@ 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(valtree) => fx.tcx.valtree_to_const_val((const_.ty(), valtree)),
+        ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
+            if fx.tcx.is_static(def.did) =>
+        {
+            assert!(substs.is_empty());
+            assert!(promoted.is_none());
+            return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty())).to_cvalue(fx);
+        }
         ConstKind::Param(_)
         | ConstKind::Infer(_)
         | ConstKind::Bound(_, _)