diff --git a/src/macros.rs b/src/macros.rs index b9c6a6a..382e568 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,19 +1,18 @@ macro_rules! test_println { ($($arg:tt)*) => { - if cfg!(test) || cfg!(all(thingbuf_trace, feature = "std")) { - if crate::util::panic::panicking() { - // getting the thread ID while panicking doesn't seem to play super nicely with loom's - // mock lazy_static... - println!("[PANIC {:>30}:{:<3}] {}", file!(), line!(), format_args!($($arg)*)) - } else { - crate::loom::traceln(format_args!( - "[{:?} {:>30}:{:<3}] {}", - crate::loom::thread::current().id(), - file!(), - line!(), - format_args!($($arg)*), - )); - } + #[cfg(all(feature = "std", any(thingbuf_trace, test)))] + if crate::util::panic::panicking() { + // getting the thread ID while panicking doesn't seem to play super nicely with loom's + // mock lazy_static... + println!("[PANIC {:>30}:{:<3}] {}", file!(), line!(), format_args!($($arg)*)) + } else { + crate::loom::traceln(format_args!( + "[{:?} {:>30}:{:<3}] {}", + crate::loom::thread::current().id(), + file!(), + line!(), + format_args!($($arg)*), + )); } } } @@ -22,7 +21,7 @@ macro_rules! test_dbg { ($e:expr) => { match $e { e => { - #[cfg(any(test, all(thingbuf_trace, feature = "std")))] + #[cfg(all(feature = "std", any(thingbuf_trace, test)))] test_println!("{} = {:?}", stringify!($e), &e); e } @@ -40,7 +39,7 @@ macro_rules! assert_dbg { }; (@$e:expr, $($msg:tt)+) => { { - #[cfg(any(test, all(thingbuf_trace, feature = "std")))] + #[cfg(all(feature = "std", any(thingbuf_trace, test)))] test_println!("ASSERT: {}{}", stringify!($e), format_args!($($msg)*)); assert!($e, $($msg)*); test_println!("-> ok"); @@ -58,7 +57,7 @@ macro_rules! assert_eq_dbg { }; (@ $a:expr, $b:expr, $($msg:tt)+) => { { - #[cfg(any(test, all(thingbuf_trace, feature = "std")))] + #[cfg(all(feature = "std", any(thingbuf_trace, test)))] test_println!("ASSERT: {} == {}{}", stringify!($a), stringify!($b), format_args!($($msg)*)); assert_eq!($a, $b, $($msg)*); test_println!("-> ok");