Print a backtrace in const eval if interrupted

This commit is contained in:
Ben Kimock 2023-05-19 16:03:35 -04:00
parent a0c20d52e0
commit 9e0d1a3284
13 changed files with 56 additions and 18 deletions

View file

@ -1,3 +1,5 @@
use std::sync::atomic::Ordering::Relaxed;
use either::{Left, Right};
use rustc_hir::def::DefKind;
@ -22,6 +24,7 @@ use crate::interpret::{
InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking,
StackPopCleanup,
};
use crate::CTRL_C_RECEIVED;
// Returns a pointer to where the result lives
#[instrument(level = "trace", skip(ecx, body))]
@ -79,7 +82,11 @@ fn eval_body_using_ecx<'mir, 'tcx, R: InterpretationResult<'tcx>>(
ecx.storage_live_for_always_live_locals()?;
// The main interpreter loop.
while ecx.step()? {}
while ecx.step()? {
if CTRL_C_RECEIVED.load(Relaxed) {
throw_exhaust!(Interrupted);
}
}
// Intern the result
intern_const_alloc_recursive(ecx, intern_kind, &ret)?;