Skip to content

Commit 5aa29c4

Browse files
committed
Fix test error
1 parent 53c6d9b commit 5aa29c4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustc_mir/interpret/const_eval.rs

+8
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ impl<'mir, 'tcx> super::Machine<'mir, 'tcx> for CompileTimeEvaluator {
339339
ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
340340
cid: GlobalId<'tcx>,
341341
) -> EvalResult<'tcx, AllocId> {
342+
let alloc = ecx
343+
.tcx
344+
.interpret_interner
345+
.get_cached(cid.instance.def_id());
346+
// Don't evaluate when already cached to prevent cycles
347+
if let Some(alloc) = alloc {
348+
return Ok(alloc)
349+
}
342350
// ensure the static is computed
343351
ecx.const_eval(cid)?;
344352
Ok(ecx

0 commit comments

Comments
 (0)