Rollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk

add err_machine_stop macro

We have that for all other error kinds, but here I somehow forgot it.

r? @oli-obk
This commit is contained in:
Mazdak Farrokhzad 2020-03-23 19:04:52 +01:00 committed by GitHub
commit 8cb3daa368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -46,6 +46,13 @@ macro_rules! err_exhaust {
}; };
} }
#[macro_export]
macro_rules! err_machine_stop {
($($tt:tt)*) => {
$crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*))
};
}
// In the `throw_*` macros, avoid `return` to make them work with `try {}`. // In the `throw_*` macros, avoid `return` to make them work with `try {}`.
#[macro_export] #[macro_export]
macro_rules! throw_unsup { macro_rules! throw_unsup {
@ -79,9 +86,7 @@ macro_rules! throw_exhaust {
#[macro_export] #[macro_export]
macro_rules! throw_machine_stop { macro_rules! throw_machine_stop {
($($tt:tt)*) => { ($($tt:tt)*) => { Err::<!, _>(err_machine_stop!($($tt)*))? };
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
};
} }
mod allocation; mod allocation;

View File

@ -5,7 +5,7 @@ use rustc::mir::AssertKind;
use rustc_span::Symbol; use rustc_span::Symbol;
use super::InterpCx; use super::InterpCx;
use crate::interpret::{ConstEvalErr, InterpError, InterpErrorInfo, Machine}; use crate::interpret::{ConstEvalErr, InterpErrorInfo, Machine};
/// The CTFE machine has some custom error kinds. /// The CTFE machine has some custom error kinds.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -21,7 +21,7 @@ pub enum ConstEvalErrKind {
// handle these. // handle these.
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind { impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
fn into(self) -> InterpErrorInfo<'tcx> { fn into(self) -> InterpErrorInfo<'tcx> {
InterpError::MachineStop(Box::new(self.to_string())).into() err_machine_stop!(self.to_string()).into()
} }
} }