diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-08-11 16:23:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-11 16:23:50 +0900 |
| commit | f50f1c79b8e8fd287d5a8679c8604f5b6929c606 (patch) | |
| tree | c490cf316b979be7cad0204eedd47675007b6254 | |
| parent | 06f296a0052d628fc516208b5e297f8ac5e40692 (diff) | |
| parent | aec6df9b944c052ed7899b150f6537c6c6fae535 (diff) | |
| download | rust-f50f1c79b8e8fd287d5a8679c8604f5b6929c606.tar.gz rust-f50f1c79b8e8fd287d5a8679c8604f5b6929c606.zip | |
Rollup merge of #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.
| -rw-r--r-- | src/librustc_mir/const_eval/machine.rs | 9 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc_mir/const_eval/machine.rs b/src/librustc_mir/const_eval/machine.rs index 0dac8b64910..3a753a0edb6 100644 --- a/src/librustc_mir/const_eval/machine.rs +++ b/src/librustc_mir/const_eval/machine.rs @@ -301,6 +301,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, Ok(()) } + fn after_stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { + // Enforce stack size limit. + if !ecx.tcx.sess.recursion_limit().value_within_limit(ecx.stack().len()) { + throw_exhaust!(StackFrameLimitReached) + } else { + Ok(()) + } + } + #[inline(always)] fn stack( ecx: &'a InterpCx<'mir, 'tcx, Self>, diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 7c2f749c156..bcf2899b439 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -687,11 +687,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { M::after_stack_push(self)?; info!("ENTERING({}) {}", self.frame_idx(), self.frame().instance); - if !self.tcx.sess.recursion_limit().value_within_limit(self.stack().len()) { - throw_exhaust!(StackFrameLimitReached) - } else { - Ok(()) - } + Ok(()) } /// Jump to the given block. |
