Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f50f1c7

Browse files
authored
Rollup merge of rust-lang#75338 - RalfJung:const-eval-stack-size-check, r=oli-obk
move stack size check to const_eval machine This is consistent with how we enforce the step limit. In particular, we do not want this limit checked for Miri-the-tool.
2 parents 06f296a + aec6df9 commit f50f1c7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustc_mir/const_eval/machine.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
301301
Ok(())
302302
}
303303

304+
fn after_stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
305+
// Enforce stack size limit.
306+
if !ecx.tcx.sess.recursion_limit().value_within_limit(ecx.stack().len()) {
307+
throw_exhaust!(StackFrameLimitReached)
308+
} else {
309+
Ok(())
310+
}
311+
}
312+
304313
#[inline(always)]
305314
fn stack(
306315
ecx: &'a InterpCx<'mir, 'tcx, Self>,

src/librustc_mir/interpret/eval_context.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
687687
M::after_stack_push(self)?;
688688
info!("ENTERING({}) {}", self.frame_idx(), self.frame().instance);
689689

690-
if !self.tcx.sess.recursion_limit().value_within_limit(self.stack().len()) {
691-
throw_exhaust!(StackFrameLimitReached)
692-
} else {
693-
Ok(())
694-
}
690+
Ok(())
695691
}
696692

697693
/// Jump to the given block.

0 commit comments

Comments
 (0)