Skip to content

Commit 9520551

Browse files
committed
Explain why const_eval is ok here
1 parent 0e3fafa commit 9520551

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
588588
} else {
589589
self.param_env
590590
};
591+
// We use `const_eval` here and `const_eval_raw` elsewhere in mir interpretation.
592+
// The reason we use `const_eval_raw` everywhere else is to prevent cycles during
593+
// validation, because validation automatically reads through any references, thus
594+
// potentially requiring the current static to be evaluated again. This is not a
595+
// problem here, because we need an operand and operands are always reads.
596+
// FIXME(oli-obk): eliminate all the `const_eval_raw` usages when we get rid of
597+
// `StaticKind` once and for all.
591598
let val =
592599
self.tcx.const_eval(param_env.and(GlobalId { instance, promoted: None }))?;
593600
// "recurse". This is only ever going into a recusion depth of 1, because after

0 commit comments

Comments
 (0)