about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-23 17:13:25 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-26 22:50:18 +0100
commitaaffe12453bd98268fda8b5397eff7998ef2ea55 (patch)
tree7fd8801eebeddebce546d4d0b1f2fb54daeab35b /src
parentb476344ccc877cd0a2bdb5673928f51fd80b4a79 (diff)
downloadrust-aaffe12453bd98268fda8b5397eff7998ef2ea55.tar.gz
rust-aaffe12453bd98268fda8b5397eff7998ef2ea55.zip
Use the targetted const eval functions
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/eval_context.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index bc158a767ce..766ef6ab6fe 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -758,17 +758,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         &self,
         gid: GlobalId<'tcx>,
     ) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
-        // For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
-        // and thus don't care about the parameter environment. While we could just use
-        // `self.param_env`, that would mean we invoke the query to evaluate the static
-        // with different parameter environments, thus causing the static to be evaluated
-        // multiple times.
-        let param_env = if self.tcx.is_static(gid.instance.def_id()) {
-            ty::ParamEnv::reveal_all()
+        let val = if self.tcx.is_static(gid.instance.def_id()) {
+            self.tcx.const_eval_poly(gid.instance.def_id())?
+        } else if let Some(promoted) = gid.promoted {
+            self.tcx.const_eval_promoted(gid.instance, promoted)?
         } else {
-            self.param_env
+            self.tcx.const_eval_instance(self.param_env, gid.instance, Some(self.tcx.span))?
         };
-        let val = self.tcx.const_eval(param_env.and(gid))?;
         // Even though `ecx.const_eval` is called from `eval_const_to_op` we can never have a
         // recursion deeper than one level, because the `tcx.const_eval` above is guaranteed to not
         // return `ConstValue::Unevaluated`, which is the only way that `eval_const_to_op` will call