diff --git a/hir/src/lib.rs b/hir/src/lib.rs index a9b00421..2c9dc690 100644 --- a/hir/src/lib.rs +++ b/hir/src/lib.rs @@ -7,6 +7,46 @@ pub use miden_hir_type::{FunctionType, Type, TypeRepr}; pub type Felt = winter_math::fields::f64::BaseElement; +macro_rules! assert_matches { + ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => { + match $left { + $( $pattern )|+ $( if $guard )? => {} + ref left_val => { + panic!(r#" +assertion failed: `(left matches right)` + left: `{:?}`, + right: `{}`"#, left_val, stringify!($($pattern)|+ $(if $guard)?)); + } + } + }; + + ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal $(,)?) => { + match $left { + $( $pattern )|+ $( if $guard )? => {} + ref left_val => { + panic!(concat!(r#" +assertion failed: `(left matches right)` + left: `{:?}`, + right: `{}` +"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?)); + } + } + }; + + ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal, $($arg:tt)+) => { + match $left { + $( $pattern )|+ $( if $guard )? => {} + ref left_val => { + panic!(concat!(r#" +assertion failed: `(left matches right)` + left: `{:?}`, + right: `{}` +"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?), $($arg)+); + } + } + } +} + mod asm; mod block; mod builder;