|
@@ -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");
|
|
@@ -96,29 +95,32 @@ macro_rules! fmt_bits {
|
|
|
|
|
|
#[allow(unused_macros)]
|
|
|
macro_rules! unreachable_unchecked {
|
|
|
- ($($arg:tt)+) => {
|
|
|
- crate::unreachable_unchecked!(@inner , format_args!(": {}", format_args!($($arg)*)))
|
|
|
+ (@inner $msg:expr) => {
|
|
|
+ {
|
|
|
+ #[cfg(debug_assertions)] {
|
|
|
+ panic!(
|
|
|
+ "internal error: entered unreachable code{}\n\n\
|
|
|
+ /!\\ EXTREMELY SERIOUS WARNING /!\\\n
|
|
|
+ This code should NEVER be entered; in release mode, this would \
|
|
|
+ have been an `unreachable_unchecked` hint. The fact that this \
|
|
|
+ occurred means something VERY bad is going on. \n\
|
|
|
+ Please contact the `thingbuf` maintainers immediately. Sorry!",
|
|
|
+ $msg,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ #[cfg(not(debug_assertions))]
|
|
|
+ unsafe {
|
|
|
+ core::hint::unreachable_unchecked();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
- () => {
|
|
|
- crate::unreachable_unchecked!(@inner ".")
|
|
|
+ ($($arg:tt)+) => {
|
|
|
+ unreachable_unchecked!(@inner format_args!(": {}", format_args!($($arg)*)))
|
|
|
};
|
|
|
|
|
|
- (@inner $msg:expr) => {
|
|
|
- #[cfg(debug_assertions)] {
|
|
|
- panic!(
|
|
|
- "internal error: entered unreachable code{}\n\n\
|
|
|
- /!\\ EXTREMELY SERIOUS WARNING /!\\\n
|
|
|
- This code should NEVER be entered; in release mode, this would \
|
|
|
- have been an `unreachable_unchecked` hint. The fact that this \
|
|
|
- occurred means something VERY bad is going on. \n\
|
|
|
- Please contact the `thingbuf` maintainers immediately. Sorry!",
|
|
|
- $msg,
|
|
|
- );
|
|
|
- }
|
|
|
- #[cfg(not(debug_assertions))]
|
|
|
- unsafe {
|
|
|
- core::hint::unreachable_unchecked();
|
|
|
- }
|
|
|
+ () => {
|
|
|
+ unreachable_unchecked!(@inner ".")
|
|
|
};
|
|
|
}
|