Skip to content

Commit 41d5818

Browse files
committed
Explain ParamEnv::reveal_all usage
1 parent 6b651b1 commit 41d5818

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
578578
ty::ConstKind::Param(_) => throw_inval!(TooGeneric),
579579
ty::ConstKind::Unevaluated(def_id, substs) => {
580580
let instance = self.resolve(def_id, substs)?;
581+
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
582+
// and thus don't care about the parameter environment. While we could just use
583+
// `self.param_env`, that would mean we invoke the query to evaluate the static
584+
// with different parameter environments, thus causing the static to be evaluated
585+
// multiple times.
581586
let param_env = if self.tcx.is_static(def_id) {
582587
ty::ParamEnv::reveal_all()
583588
} else {

0 commit comments

Comments
 (0)