1
0
Fork 0

Promote debug assertion failures to warnings

This commit is contained in:
Robbert van der Helm 2023-12-30 15:01:32 +01:00
parent 4511d9f8fd
commit 9a9b7cd7b9
2 changed files with 11 additions and 8 deletions

View file

@ -37,6 +37,9 @@ state is to list breaking changes.
libraries that link against a different version of `raw_window_handle` than libraries that link against a different version of `raw_window_handle` than
the one used by NIH-plug itself by simply wrapping around the one used by NIH-plug itself by simply wrapping around
`ParentWindowHandle`. `ParentWindowHandle`.
- `nih_debug_assert*!()` failures are now promoted to a warning instead of a
debug message. This makes the non-fatal debug assertion failures easier to
spot.
## [2023-12-30] ## [2023-12-30]

View file

@ -94,7 +94,7 @@ macro_rules! nih_debug_assert {
if cfg!(test) { if cfg!(test) {
debug_assert!($cond); debug_assert!($cond);
} else if cfg!(debug_assertions) && !$cond { } else if cfg!(debug_assertions) && !$cond {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond)))); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($cond))));
} }
); );
($cond:expr, $format:expr $(, $($args:tt)*)?) => ( ($cond:expr, $format:expr $(, $($args:tt)*)?) => (
@ -102,7 +102,7 @@ macro_rules! nih_debug_assert {
if cfg!(test) { if cfg!(test) {
debug_assert!($cond, $format, $($($args)*)?); debug_assert!($cond, $format, $($($args)*)?);
} else if cfg!(debug_assertions) && !$cond { } else if cfg!(debug_assertions) && !$cond {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?)); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?));
} }
); );
} }
@ -117,14 +117,14 @@ macro_rules! nih_debug_assert_failure {
if cfg!(test) { if cfg!(test) {
debug_assert!(false, "Debug assertion failed"); debug_assert!(false, "Debug assertion failed");
} else if cfg!(debug_assertions) { } else if cfg!(debug_assertions) {
$crate::util::permit_alloc(|| $crate::log::debug!("Debug assertion failed")); $crate::util::permit_alloc(|| $crate::log::warn!("Debug assertion failed"));
} }
); );
($format:expr $(, $($args:tt)*)?) => ( ($format:expr $(, $($args:tt)*)?) => (
if cfg!(test) { if cfg!(test) {
debug_assert!(false, concat!("Debug assertion failed: ", $format), $($($args)*)?); debug_assert!(false, concat!("Debug assertion failed: ", $format), $($($args)*)?);
} else if cfg!(debug_assertions) { } else if cfg!(debug_assertions) {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", $format), $($($args)*)?)); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", $format), $($($args)*)?));
} }
); );
} }
@ -140,7 +140,7 @@ macro_rules! nih_debug_assert_eq {
if cfg!(test) { if cfg!(test) {
debug_assert_eq!($left, $right); debug_assert_eq!($left, $right);
} else if cfg!(debug_assertions) && $left != $right { } else if cfg!(debug_assertions) && $left != $right {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right)))); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right))));
} }
); );
($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => (
@ -148,7 +148,7 @@ macro_rules! nih_debug_assert_eq {
if cfg!(test) { if cfg!(test) {
debug_assert_eq!($left, $right, $format, $($($args)*)?); debug_assert_eq!($left, $right, $format, $($($args)*)?);
} else if cfg!(debug_assertions) && $left != $right { } else if cfg!(debug_assertions) && $left != $right {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?)); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?));
} }
); );
} }
@ -164,7 +164,7 @@ macro_rules! nih_debug_assert_ne {
if cfg!(test) { if cfg!(test) {
debug_assert_ne!($left, $right); debug_assert_ne!($left, $right);
} else if cfg!(debug_assertions) && $left == $right { } else if cfg!(debug_assertions) && $left == $right {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right)))); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right))));
} }
); );
($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => (
@ -172,7 +172,7 @@ macro_rules! nih_debug_assert_ne {
if cfg!(test) { if cfg!(test) {
debug_assert_ne!($left, $right, $format, $($($args)*)?); debug_assert_ne!($left, $right, $format, $($($args)*)?);
} else if cfg!(debug_assertions) && $left == $right { } else if cfg!(debug_assertions) && $left == $right {
$crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?)); $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?));
} }
); );
} }