Skip to content

Commit aaffe12

Browse files
committed
Use the targetted const eval functions
1 parent b476344 commit aaffe12

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,17 +758,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
758758
&self,
759759
gid: GlobalId<'tcx>,
760760
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
761-
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
762-
// and thus don't care about the parameter environment. While we could just use
763-
// `self.param_env`, that would mean we invoke the query to evaluate the static
764-
// with different parameter environments, thus causing the static to be evaluated
765-
// multiple times.
766-
let param_env = if self.tcx.is_static(gid.instance.def_id()) {
767-
ty::ParamEnv::reveal_all()
761+
let val = if self.tcx.is_static(gid.instance.def_id()) {
762+
self.tcx.const_eval_poly(gid.instance.def_id())?
763+
} else if let Some(promoted) = gid.promoted {
764+
self.tcx.const_eval_promoted(gid.instance, promoted)?
768765
} else {
769-
self.param_env
766+
self.tcx.const_eval_instance(self.param_env, gid.instance, Some(self.tcx.span))?
770767
};
771-
let val = self.tcx.const_eval(param_env.and(gid))?;
772768
// Even though `ecx.const_eval` is called from `eval_const_to_op` we can never have a
773769
// recursion deeper than one level, because the `tcx.const_eval` above is guaranteed to not
774770
// return `ConstValue::Unevaluated`, which is the only way that `eval_const_to_op` will call

0 commit comments

Comments
 (0)