about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/consts.rs
diff options
context:
space:
mode:
authorBen Lewis <benlewisj@gmail.com>2019-11-30 08:42:56 +1300
committerBen Lewis <benlewisj@gmail.com>2019-12-22 11:15:16 +1300
commitc010d843aacc32ed2bc03d36121aa7f6e08ef045 (patch)
treef7c32850d56e82f8ce0518e865fadff0cd7cbc74 /src/librustc_codegen_llvm/consts.rs
parent6b561b4917e803c4be4ca44d8e552b680cb9e380 (diff)
downloadrust-c010d843aacc32ed2bc03d36121aa7f6e08ef045.tar.gz
rust-c010d843aacc32ed2bc03d36121aa7f6e08ef045.zip
Add simpler entry points to const eval for common usages.
Diffstat (limited to 'src/librustc_codegen_llvm/consts.rs')
-rw-r--r--src/librustc_codegen_llvm/consts.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs
index 11a105c1828..c048321e383 100644
--- a/src/librustc_codegen_llvm/consts.rs
+++ b/src/librustc_codegen_llvm/consts.rs
@@ -8,7 +8,7 @@ use crate::value::Value;
 use libc::c_uint;
 use rustc::hir::def_id::DefId;
 use rustc::mir::interpret::{ConstValue, Allocation, read_target_uint,
-    Pointer, ErrorHandled, GlobalId};
+    Pointer, ErrorHandled};
 use rustc::mir::mono::MonoItem;
 use rustc::hir::Node;
 use rustc_target::abi::HasDataLayout;
@@ -81,13 +81,7 @@ pub fn codegen_static_initializer(
     cx: &CodegenCx<'ll, 'tcx>,
     def_id: DefId,
 ) -> Result<(&'ll Value, &'tcx Allocation), ErrorHandled> {
-    let instance = ty::Instance::mono(cx.tcx, def_id);
-    let cid = GlobalId {
-        instance,
-        promoted: None,
-    };
-    let param_env = ty::ParamEnv::reveal_all();
-    let static_ = cx.tcx.const_eval(param_env.and(cid))?;
+    let static_ = cx.tcx.const_eval_poly(def_id)?;
 
     let alloc = match static_.val {
         ty::ConstKind::Value(ConstValue::ByRef {