//! An interpreter for MIR used in CTFE and by miri
#[macro_export]
-macro_rules! throw_unsup {
- ($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_inval {
- ($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_ub {
+macro_rules! err_unsup {
($($tt:tt)*) => {
- return Err($crate::mir::interpret::InterpError::UndefinedBehaviour(
- $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
- ).into())
+ $crate::mir::interpret::InterpError::Unsupported(
+ $crate::mir::interpret::UnsupportedOpInfo::$($tt)*
+ )
};
}
-#[macro_export]
-macro_rules! throw_panic {
- ($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) };
-}
-
-#[macro_export]
-macro_rules! throw_exhaust {
- ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
-}
-
#[macro_export]
macro_rules! err_inval {
($($tt:tt)*) => {
}
#[macro_export]
-macro_rules! err_unsup {
+macro_rules! err_ub {
($($tt:tt)*) => {
- $crate::mir::interpret::InterpError::Unsupported(
- $crate::mir::interpret::UnsupportedOpInfo::$($tt)*
+ $crate::mir::interpret::InterpError::UndefinedBehaviour(
+ $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
+ )
+ };
+}
+
+#[macro_export]
+macro_rules! err_panic {
+ ($($tt:tt)*) => {
+ $crate::mir::interpret::InterpError::Panic(
+ $crate::mir::interpret::PanicInfo::$($tt)*
)
};
}
}
#[macro_export]
-macro_rules! err_panic {
+macro_rules! throw_unsup {
+ ($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_inval {
+ ($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_ub {
($($tt:tt)*) => {
- $crate::mir::interpret::InterpError::Panic(
- $crate::mir::interpret::PanicInfo::$($tt)*
- )
+ return Err($crate::mir::interpret::InterpError::UndefinedBehaviour(
+ $crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
+ ).into())
};
}
+#[macro_export]
+macro_rules! throw_panic {
+ ($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) };
+}
+
+#[macro_export]
+macro_rules! throw_exhaust {
+ ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
+}
+
mod error;
mod value;
mod allocation;
use rustc::mir::interpret::InterpError::*;
match diagnostic.error {
Exit(_) => bug!("the CTFE program cannot exit"),
- | Unsupported(_) => {},
- | UndefinedBehaviour(_) => {},
- | InvalidProgram(_) => {},
- | ResourceExhaustion(_) => {},
- | Panic(_)
- => {
+ Panic(_) => {
diagnostic.report_as_lint(
self.ecx.tcx,
"this expression will panic at runtime",
None,
);
}
+ _ => {},
}
None
},