1
Fork 0

fix span of stack size error

This commit is contained in:
Ralf Jung 2020-08-12 10:18:21 +02:00
parent a505e773a5
commit fd32fe9bb9
5 changed files with 22 additions and 19 deletions

View file

@ -301,12 +301,16 @@ 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()) {
#[inline(always)]
fn init_frame_extra(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
frame: Frame<'mir, 'tcx>,
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
// Enforce stack size limit. Add 1 because this is run before the new frame is pushed.
if !ecx.tcx.sess.recursion_limit().value_within_limit(ecx.stack().len() + 1) {
throw_exhaust!(StackFrameLimitReached)
} else {
Ok(())
Ok(frame)
}
}

View file

@ -409,12 +409,4 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
) -> Self::PointerTag {
()
}
#[inline(always)]
fn init_frame_extra(
_ecx: &mut InterpCx<$mir, $tcx, Self>,
frame: Frame<$mir, $tcx>,
) -> InterpResult<$tcx, Frame<$mir, $tcx>> {
Ok(frame)
}
}

View file

@ -281,6 +281,14 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
Ok(())
}
#[inline(always)]
fn init_frame_extra(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
frame: Frame<'mir, 'tcx>,
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
Ok(frame)
}
#[inline(always)]
fn stack(
ecx: &'a InterpCx<'mir, 'tcx, Self>,

View file

@ -1,11 +1,11 @@
// build-fail
pub const unsafe fn fake_type<T>() -> T {
hint_unreachable() //~ ERROR evaluation of constant value failed
hint_unreachable()
}
pub const unsafe fn hint_unreachable() -> ! {
fake_type()
fake_type() //~ ERROR evaluation of constant value failed
}
trait Const {

View file

@ -1,11 +1,9 @@
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited-const-issue-61744.rs:4:5
--> $DIR/uninhabited-const-issue-61744.rs:8:5
|
LL | hint_unreachable()
| ^^^^^^^^^^^^^^^^^^
| ------------------
| |
| reached the configured maximum number of stack frames
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
@ -72,8 +70,9 @@ LL | hint_unreachable()
| inside `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:4:5
...
LL | fake_type()
| -----------
| ^^^^^^^^^^^
| |
| reached the configured maximum number of stack frames
| inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5
| inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5
| inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5