123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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)*),
- ));
- }
- }
- }
- }
- macro_rules! test_dbg {
- ($e:expr) => {
- match $e {
- e => {
- #[cfg(test)]
- test_println!("{} = {:?}", stringify!($e), &e);
- e
- }
- }
- };
- }
- macro_rules! feature {
- (
- #![$meta:meta]
- $($item:item)*
- ) => {
- $(
- #[cfg($meta)]
- #[cfg_attr(docsrs, doc(cfg($meta)))]
- $item
- )*
- }
- }
- #[allow(unused_macros)]
- macro_rules! unreachable_unchecked {
- ($($arg:tt)+) => {
- crate::unreachable_unchecked!(@inner , format_args!(": {}", format_args!($($arg)*)))
- };
- () => {
- crate::unreachable_unchecked!(@inner ".")
- };
- (@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();
- }
- };
- }
|