about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorBen Lewis <benlewisj@gmail.com>2020-02-15 11:56:23 +1300
committerBen Lewis <benlewisj@gmail.com>2020-02-15 11:56:23 +1300
commitc423a8649c0bac16fd4d1b9cbea657e4245bb5ac (patch)
tree0955bf073db63900684d694eea8a6939c92d1b53 /src/librustc_codegen_llvm
parente168dcd254d0a6a0cbaad5f2c054ce5116a07119 (diff)
downloadrust-c423a8649c0bac16fd4d1b9cbea657e4245bb5ac.tar.gz
rust-c423a8649c0bac16fd4d1b9cbea657e4245bb5ac.zip
Change const eval to return `ConstValue`, instead of `Const` as the type inside it shouldn't be used.
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/consts.rs8
-rw-r--r--src/librustc_codegen_llvm/intrinsic.rs3
2 files changed, 5 insertions, 6 deletions
diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs
index 38090cb26bc..09a84aff168 100644
--- a/src/librustc_codegen_llvm/consts.rs
+++ b/src/librustc_codegen_llvm/consts.rs
@@ -78,11 +78,9 @@ pub fn codegen_static_initializer(
     cx: &CodegenCx<'ll, 'tcx>,
     def_id: DefId,
 ) -> Result<(&'ll Value, &'tcx Allocation), ErrorHandled> {
-    let static_ = cx.tcx.const_eval_poly(def_id)?;
-
-    let alloc = match static_.val {
-        ty::ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc,
-        _ => bug!("static const eval returned {:#?}", static_),
+    let alloc = match cx.tcx.const_eval_poly(def_id)? {
+        ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc,
+        val => bug!("static const eval returned {:#?}", val),
     };
     Ok((const_alloc_to_llvm(cx, alloc), alloc))
 }
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 031837c1efb..341a4a77c3c 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -193,7 +193,8 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
                     .tcx
                     .const_eval_instance(ty::ParamEnv::reveal_all(), instance, None)
                     .unwrap();
-                OperandRef::from_const(self, ty_name).immediate_or_packed_pair(self)
+                let const_ = ty::Const { val: ty::ConstKind::Value(ty_name), ty: ret_ty };
+                OperandRef::from_const(self, &const_).immediate_or_packed_pair(self)
             }
             "init" => {
                 let ty = substs.type_at(0);