Use the more-asserts crate in more places.
This provides assert_le, assert_lt, and so on, which can print the values of the operands.
This commit is contained in:
@@ -9,6 +9,7 @@ use core::{fmt, mem};
|
||||
use cranelift_codegen::binemit;
|
||||
use dynasmrt::DynasmApi;
|
||||
use either::{Either, Left, Right};
|
||||
use more_asserts::assert_ge;
|
||||
use multi_mut::HashMapMultiMut;
|
||||
use std::{collections::HashMap, hash::Hash};
|
||||
|
||||
@@ -152,26 +153,6 @@ where
|
||||
block.is_next = true;
|
||||
}
|
||||
|
||||
macro_rules! assert_ge {
|
||||
($left:expr, $right:expr) => ({
|
||||
match (&$left, &$right) {
|
||||
(left_val, right_val) => {
|
||||
if !(*left_val >= *right_val) {
|
||||
// The reborrows below are intentional. Without them, the stack slot for the
|
||||
// borrow is initialized even before the values are compared, leading to a
|
||||
// noticeable slow down.
|
||||
panic!(r#"assertion failed: `(left >= right)`
|
||||
left: `{:?}`,
|
||||
right: `{:?}`"#, &*left_val, &*right_val)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
($left:expr, $right:expr,) => ({
|
||||
assert_ge!($left, $right)
|
||||
});
|
||||
}
|
||||
|
||||
// `cfg` on blocks doesn't work in the compiler right now, so we have to write a dummy macro
|
||||
#[cfg(debug_assertions)]
|
||||
macro_rules! assertions {
|
||||
|
||||
Reference in New Issue
Block a user