const_format/macros/
assertions.rs

1#[cfg(feature = "assertc")]
2mod assertc_macros;
3
4#[cfg(feature = "assertcp")]
5mod assertcp_macros;
6
7#[doc(hidden)]
8#[macro_export]
9macro_rules! __assertc_inner {
10    (
11        $fmt_macro:ident
12        ($($parameters:tt)*)
13        ($cond:expr $(, $fmt_literal:expr $(,$fmt_arg:expr)*)? $(,)?)
14    ) => {
15        #[allow(non_snake_case)]
16        const _: () = {
17            use $crate::__cf_osRcTFl4A;
18
19            $crate::__assertc_common!{
20                $fmt_macro
21                ($($parameters)*)
22                ($cond)
23                (
24                    concat!(
25                        "\nassertion failed.\n",
26                        $($fmt_literal,)?
27                        "\n",
28                    )
29                    $($(,$fmt_arg)*)?
30                )
31            }
32        };
33    }
34}
35
36#[doc(hidden)]
37#[macro_export]
38macro_rules! __assertc_common {
39    (
40        $fmt_macro:ident
41        ($($span:tt)*)
42        ($cond:expr)
43        ($($fmt_literal:expr $(,$fmt_arg:expr)*)?)
44    ) => (
45        const PANIC_IF_TRUE_NHPMWYD3NJA: bool = !($cond);
46
47        const MSG_NHPMWYD3NJA: &str = $crate::pmr::$fmt_macro!(
48            (PANIC_IF_TRUE_NHPMWYD3NJA)
49            ($($fmt_literal,)?),
50            $($($fmt_arg,)*)?
51        );
52
53        __cf_osRcTFl4A::pmr::respan_to!{
54            ($($span)*)
55            __cf_osRcTFl4A::pmr::assert_(PANIC_IF_TRUE_NHPMWYD3NJA, MSG_NHPMWYD3NJA)
56        }
57    );
58}