Skip to content

Commit aec6df9

Browse files
committed
move stack size check to const_eval machine
1 parent 8bc801b commit aec6df9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustc_mir/const_eval/machine.rs

+9
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

+1-5
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
653653
M::after_stack_push(self)?;
654654
info!("ENTERING({}) {}", self.frame_idx(), self.frame().instance);
655655

656-
if !self.tcx.sess.recursion_limit().value_within_limit(self.stack().len()) {
657-
throw_exhaust!(StackFrameLimitReached)
658-
} else {
659-
Ok(())
660-
}
656+
Ok(())
661657
}
662658

663659
/// Jump to the given block.

0 commit comments

Comments
 (0)