Skip to content

Commit

Permalink
Rollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk
Browse files Browse the repository at this point in the history
add err_machine_stop macro

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

r? @oli-obk
  • Loading branch information
Centril committed Mar 23, 2020
2 parents 560eae3 + 4803f29 commit 8cb3daa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}`.
#[macro_export]
macro_rules! throw_unsup {
Expand Down Expand Up @@ -79,9 +86,7 @@ macro_rules! throw_exhaust {

#[macro_export]
macro_rules! throw_machine_stop {
($($tt:tt)*) => {
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
};
($($tt:tt)*) => { Err::<!, _>(err_machine_stop!($($tt)*))? };
}

mod allocation;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/const_eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc::mir::AssertKind;
use rustc_span::Symbol;

use super::InterpCx;
use crate::interpret::{ConstEvalErr, InterpError, InterpErrorInfo, Machine};
use crate::interpret::{ConstEvalErr, InterpErrorInfo, Machine};

/// The CTFE machine has some custom error kinds.
#[derive(Clone, Debug)]
Expand All @@ -21,7 +21,7 @@ pub enum ConstEvalErrKind {
// handle these.
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
fn into(self) -> InterpErrorInfo<'tcx> {
InterpError::MachineStop(Box::new(self.to_string())).into()
err_machine_stop!(self.to_string()).into()
}
}

Expand Down

0 comments on commit 8cb3daa

Please sign in to comment.