abort() now takes a msg parameter
This commit is contained in:
parent
4f9fd2a5d4
commit
d366ed2730
@ -20,6 +20,7 @@ pub enum ConstEvalErrKind {
|
||||
ModifiedGlobal,
|
||||
AssertFailure(AssertKind<ConstInt>),
|
||||
Panic { msg: Symbol, line: u32, col: u32, file: Symbol },
|
||||
Abort(String),
|
||||
}
|
||||
|
||||
// The errors become `MachineStop` with plain strings when being raised.
|
||||
@ -46,6 +47,7 @@ impl fmt::Display for ConstEvalErrKind {
|
||||
Panic { msg, line, col, file } => {
|
||||
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col)
|
||||
}
|
||||
Abort(ref msg) => write!(f, "{}", msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
None => match intrinsic_name {
|
||||
sym::transmute => throw_ub_format!("transmuting to uninhabited type"),
|
||||
sym::unreachable => throw_ub!(Unreachable),
|
||||
sym::abort => M::abort(self)?,
|
||||
sym::abort => M::abort(self, "aborted execution".to_owned())?,
|
||||
// Unsupported diverging intrinsic.
|
||||
_ => return Ok(false),
|
||||
},
|
||||
@ -412,7 +412,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
let layout = self.layout_of(ty)?;
|
||||
|
||||
if layout.abi.is_uninhabited() {
|
||||
throw_ub_format!("attempted to instantiate uninhabited type `{}`", ty);
|
||||
M::abort(self, format!("attempted to instantiate uninhabited type `{}`", ty))?;
|
||||
}
|
||||
}
|
||||
sym::simd_insert => {
|
||||
|
@ -176,8 +176,10 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
||||
) -> InterpResult<'tcx>;
|
||||
|
||||
/// Called to evaluate `Abort` MIR terminator.
|
||||
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, !> {
|
||||
throw_unsup_format!("aborting execution is not supported")
|
||||
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>, msg: String) -> InterpResult<'tcx, !> {
|
||||
use crate::const_eval::ConstEvalErrKind;
|
||||
|
||||
Err(ConstEvalErrKind::Abort(msg).into())
|
||||
}
|
||||
|
||||
/// Called for all binary operations where the LHS has pointer type.
|
||||
|
@ -110,7 +110,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
Abort => {
|
||||
M::abort(self)?;
|
||||
M::abort(self, "aborted execution".to_owned())?;
|
||||
}
|
||||
|
||||
// When we encounter Resume, we've finished unwinding
|
||||
|
Loading…
Reference in New Issue
Block a user