Skip to content

Commit 8cb3daa

Browse files
authored
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
2 parents 560eae3 + 4803f29 commit 8cb3daa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustc/mir/interpret/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ macro_rules! err_exhaust {
4646
};
4747
}
4848

49+
#[macro_export]
50+
macro_rules! err_machine_stop {
51+
($($tt:tt)*) => {
52+
$crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*))
53+
};
54+
}
55+
4956
// In the `throw_*` macros, avoid `return` to make them work with `try {}`.
5057
#[macro_export]
5158
macro_rules! throw_unsup {
@@ -79,9 +86,7 @@ macro_rules! throw_exhaust {
7986

8087
#[macro_export]
8188
macro_rules! throw_machine_stop {
82-
($($tt:tt)*) => {
83-
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
84-
};
89+
($($tt:tt)*) => { Err::<!, _>(err_machine_stop!($($tt)*))? };
8590
}
8691

8792
mod allocation;

src/librustc_mir/const_eval/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::mir::AssertKind;
55
use rustc_span::Symbol;
66

77
use super::InterpCx;
8-
use crate::interpret::{ConstEvalErr, InterpError, InterpErrorInfo, Machine};
8+
use crate::interpret::{ConstEvalErr, InterpErrorInfo, Machine};
99

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

0 commit comments

Comments
 (0)