#[cfg_attr(feature = "docsrs", doc(cfg(feature = "non_basic")))]
#[macro_export]
macro_rules! impl_panicfmt {
(
$(# $attrs:tt)*
$kind:ident $typename:ident < $($rem:tt)*
) => (
const _: () = {
use $crate::{self as __cp_bCj7dq3Pud};
$crate::__impl_panicfmt_step_aaa!{
($(# $attrs)* $kind $typename)
()
($($rem)*)
}
};
);
(
$(# $attrs:tt)*
$kind:ident $typename:ident $($rem:tt)*
) => (
const _: () = {
use $crate::{self as __cp_bCj7dq3Pud};
$crate::__impl_panicfmt_step_aaa!{
($(# $attrs)* $kind $typename)
()
(> $($rem)*)
}
};
);
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_panicfmt_step_aaa {
(
($(# $attrs:tt)* struct $struct_name:ident)
$generic_params:tt
(
$(,)? >
$(( $($tupled:tt)* ))?
$(where[$($where_preds:tt)*])?;
$($rem:tt)*
)
) => (
$crate::__impl_panicfmt_step_ccc!{
[
$(# $attrs)*
struct $struct_name
$generic_params
($($($where_preds)*)?)
$($rem)*
]
[]
[
$struct_name
( $($($tupled)*)? )
]
}
);
(
($(# $attrs:tt)* struct $struct_name:ident)
$generic_params:tt
(
$(,)? >
$(where[$($where_preds:tt)*])?
$(( $($tupled:tt)* ))?;
$($rem:tt)*
)
) => (
compile_error!{"the where clause must come after the tuple struct fields"}
);
(
($(# $attrs:tt)* struct $struct_name:ident)
$generic_params:tt
(
$(,)?>
$(where[$($where_preds:tt)*])?
{ $($braced:tt)* }
$($rem:tt)*
)
) => (
$crate::__impl_panicfmt_step_ccc!{
[
$(# $attrs)*
struct $struct_name
$generic_params
($($($where_preds)*)?)
$($rem)*
]
[]
[
$struct_name
{ $($braced)* }
]
}
);
(
($(# $attrs:tt)* enum $enum_name:ident)
$generic_params:tt
(
$(,)?>
$(where[$($where_preds:tt)*])?
{
$(
$variant:ident $({ $($braced:tt)* })? $(( $($tupled:tt)* ))?
),*
$(,)?
}
$($rem:tt)*
)
) => (
$crate::__impl_panicfmt_step_ccc!{
[
$(# $attrs)*
enum $enum_name
$generic_params
($($($where_preds)*)?)
$($rem)*
]
[]
[
$(
$variant $({ $($braced)* })? $(( $($tupled)* ))?,
)*
]
}
);
(
$fixed:tt
($($prev_params:tt)*)
($(,)? $(ignore)? $lifetime:lifetime $($rem:tt)*)
) => (
$crate::__impl_panicfmt_step_aaa!{
$fixed
($($prev_params)* ($lifetime ($lifetime) ignore ('_)) )
($($rem)*)
}
);
(
$fixed:tt
$prev_params:tt
($(,)? $(ignore $(($($const_def:tt)*))? )? const $const_param:ident: $const_ty:ty , $($rem:tt)*)
) => (
$crate::__impl_panicfmt_step_aaa_const!{
$fixed
($(ignore $(($($const_def)*))? )?)
$prev_params
($const_param: $const_ty)
($($rem)*)
}
);
(
$fixed:tt
$prev_params:tt
($(,)? $(ignore $(($($const_def:tt)*))? )? const $const_param:ident: $const_ty:ty > $($rem:tt)*)
) => (
$crate::__impl_panicfmt_step_aaa_const!{
$fixed
($(ignore $(($($const_def)*))? )?)
$prev_params
($const_param: $const_ty)
(> $($rem)*)
}
);
(
$fixed:tt
($($prev_params:tt)*)
($(,)? ignore $(($ignore_ty:ty))? $type_param:ident $($rem:tt)*)
) => (
$crate::__impl_panicfmt_step_aaa!{
$fixed
($($prev_params)* ($type_param ($type_param) ignore (($($ignore_ty)?)) ) )
($($rem)*)
}
);
(
$fixed:tt
($($prev_params:tt)*)
($(,)? $type_param:ident $($rem:tt)*)
) => (
$crate::__impl_panicfmt_step_aaa!{
$fixed
(kept_type[$type_param] $($prev_params)* ($type_param ($type_param) kept ()) )
($($rem)*)
}
);
(
$fixed:tt
$prev_params:tt
($($rem:tt)+)
) => (
$crate::__::compile_error!{concat!(
"could not parse this in the generic parameter(s) of the type definition:",
stringify!($($rem:tt)+)
)}
);
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_panicfmt_step_aaa_const {
(
$fixed:tt
(ignore($const_def:expr))
($($prev_params:tt)*)
($const_param:ident: $const_ty:ty)
$rem:tt
) => {
$crate::__impl_panicfmt_step_aaa!{
$fixed
(
$($prev_params)*
(
$const_param
(const $const_param: $const_ty)
ignore ({$const_def})
)
)
$rem
}
};
(
$fixed:tt
($(ignore)?)
($($prev_params:tt)*)
($const_param:ident: $const_ty:ty)
$rem:tt
) => {
$crate::__impl_panicfmt_step_aaa!{
$fixed
(
$($prev_params)*
(
$const_param
(const $const_param: $const_ty)
ignore ({$crate::__::ConstDefault::DEFAULT})
)
)
$rem
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_panicfmt_step_ccc {
(
$kept:tt
$prev_variants:tt
[
$variant:ident
$($(@$is_brace:tt@)? {$($br_field:ident: $br_ty:ty),* $(,)*})?
$($(@$is_tuple:tt@)? ( $($tup_ty:ty),* $(,)* ))?
$(,$($rem_variants:tt)*)?
]
) => {
$crate::zip_counter_and_last!{
$crate::__impl_panicfmt_step_ccc_inner!{
$kept
$prev_variants
$variant
(
$($($is_brace)? Braced)?
$($($is_tuple)? Tupled)?
Braced
)
[$($($rem_variants)*)?]
}
($($(($br_field, $br_ty))*)? $($((, $tup_ty))*)?)
(
(0 fi0) (1 fi1) (2 fi2) (3 fi3) (4 fi4) (5 fi5) (6 fi6) (7 fi7)
(8 fi8) (9 fi9) (10 fi10) (11 fi11) (12 fi12) (13 fi13) (14 fi14) (15 fi15)
(16 fi16) (17 fi17) (18 fi18) (19 fi19) (20 fi20) (21 fi21) (22 fi22) (23 fi23)
(24 fi24) (25 fi25) (26 fi26) (27 fi27) (28 fi28) (29 fi29) (30 fi30) (31 fi31)
(32 fi32) (33 fi33) (34 fi34) (35 fi35) (36 fi36) (37 fi37) (38 fi38) (39 fi39)
(40 fi40) (41 fi41) (42 fi42) (43 fi43) (44 fi44) (45 fi45) (46 fi46) (47 fi47)
(48 fi48) (49 fi49) (50 fi50) (51 fi51) (52 fi52) (53 fi53) (54 fi54) (55 fi55)
(56 fi56) (57 fi57) (58 fi58) (59 fi59) (60 fi60) (61 fi61) (62 fi62) (63 fi63)
)
}
};
(
$kept:tt
[$($prev_variants:tt)*]
[
$variant:ident
$(, $($rem_variants:tt)*)?
]
) => {
$crate::__impl_panicfmt_step_ccc!{
$kept
[$($prev_variants)* ($variant Braced) ]
[$($($rem_variants)*)?]
}
};
(
$kept:tt
$variants:tt
[]
) => {
$crate::__impl_panicfmt_step__panicfmt_impl!{
$kept
variants $variants
$kept
$variants
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_panicfmt_step_ccc_inner {
(
$kept:tt
[$($prev_variants:tt)*]
$variant:ident
($delim:ident $($ignore0:tt)*)
[$($rem_variants:tt)*]
$(prefix (($($p_fname:ident)?, $p_ty:ty) ($p_index:tt $p_fi_index:tt)))*
$(last (($($l_fname:ident)?, $l_ty:ty) ($l_index:tt $l_fi_index:tt)) )?
) => {
$crate::__impl_panicfmt_step_ccc!{
$kept
[
$($prev_variants)*
(
$variant
$delim
($($l_index + 1,)? 0,)
=>
$(prefix (($($p_fname)? $p_index), ($($p_fname)? $p_fi_index), $p_ty))*
$(last (($($l_fname)? $l_index), ($($l_fname)? $l_fi_index), $l_ty))?
)
]
[$($rem_variants)*]
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_panicfmt_step__panicfmt_impl {
(
[
$(#[pfmt(display_fmt = $__display_fmt:expr)])?
$(#[pfmt(panicvals_lower_bound = $panicvals_lower_bound:expr)])?
$type_kind:ident $type_name:ident
(
$($kept_type:ident [$kept_type_:ident])*
$((
$gp_arg:tt
($($gp_param:tt)*)
$ignorance:tt
($($gp_arg_concrete:tt)*)
))*
)
($($where_preds:tt)*)
$($to_panicval_impls:tt)*
]
variants[$(
(
$variant:ident
$delimiter:ident
($field_amount:expr, $($ignore2:tt)*)
=>
$(
$is_last_field:ident
(
($fpati:tt $($ignore3:tt)?),
($fname:tt $($ignore4:tt)?),
$ty:ty
)
)*
)
)*]
$kept:tt
$variants:tt
) => (
impl<$($($gp_param)*),*> $crate::PanicFmt for $type_name<$($gp_arg),*>
where
$($kept_type_: $crate::PanicFmt,)*
$($where_preds)*
{
type This = Self;
type Kind = $crate::fmt::IsCustomType;
const PV_COUNT: $crate::__::usize = $crate::utils::slice_max_usize(&[
$(
$crate::fmt::ComputePvCount{
field_amount: $field_amount,
summed_pv_count: 0 $( + <$ty as $crate::PanicFmt>::PV_COUNT )*,
delimiter: $crate::fmt::TypeDelim::$delimiter
}.call(),
)*
$($panicvals_lower_bound)?
]);
}
macro_rules! __assert_type_name__ {
($type_name) => ()
}
$crate::__impl_to_panicvals!{
[$($kept_type)*]
[$($ignorance ($($gp_arg_concrete)*))*]
[
$type_name
[$($where_preds)*]
$((
($($gp_param)*)
$gp_arg
))*
]
[$($to_panicval_impls)*]
$kept
$variants
}
);
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_to_panicvals {
(
[$(kept_type)*]
$ignorances:tt
$gp_param:tt
[$($to_panicval_impls:tt)+]
$kept:tt
$variants:tt
) => (
$(
$crate::__impl_to_panicvals_step_aaa!{
$ignorances
$to_panicval_impls
$to_panicval_impls
$kept
$variants
}
)*
);
(
[]
$ignorances:tt
[$type_name:ident [$($where_preds:tt)*] $(( ($($gp_param:tt)*) $gp_arg:tt ))* ]
[]
$kept:tt
$variants:tt
) => (
$crate::__impl_to_panicvals_step_aaa!{
$ignorances
(
impl[$($($gp_param)*),*] $type_name<$($gp_arg),*>
where[$($where_preds)*]
)
(
impl[$($($gp_param)*),*] $type_name<$($gp_arg),*>
where[$($where_preds)*]
)
$kept
$variants
}
);
([$(kept_type)+] $ignorances:tt $gp_param:tt [] $kept:tt $variants:tt) => (
$crate::__::compile_error!{"\
type parameters must either be:\n\
- all prefixed with ignore\n\
- be replaced with concrete type arguments in \
`(impl Foo<Bar>)`s after the type definition\n\
"}
);
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_to_panicvals_step_aaa {
(
$ignorances:tt
(impl $([$($impl_param:tt)*])? $type_name:ident $(where $where_preds:tt)?)
$impl:tt
$kept:tt
$variants:tt
) => {
__assert_type_name__!{$type_name}
$crate::__impl_to_panicvals_step_bbb!{
([$($($impl_param)*)?] $type_name $kept $variants)
$ignorances
[]
[> $(where $where_preds)?]
}
};
(
$ignorances:tt
(impl $([$($impl_param:tt)*])? $type_name:ident <$($args:tt)*)
(impl $([$($impl_paramb:tt)*])? $type:path $(where $where_preds:tt)? )
$kept:tt
$variants:tt
) => {
__assert_type_name__!{$type_name}
$crate::__impl_to_panicvals_step_bbb!{
([$($($impl_param)*)?] $type $kept $variants)
$ignorances
[]
[$($args)*]
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_to_panicvals_step_bbb {
(
$kept:tt
[]
$cself:tt
[> $(where[$($where_preds:tt)*])?]
) => {
$crate::__impl_to_panicvals_finish!{
$kept
[$($($where_preds)*)?]
$cself
}
};
($kept:tt $ignorance:tt $prev_cself:tt [$(,)? $gen_arg:tt , $($rem:tt)*]) => {
$crate::__impl_to_panicvals_step_bbb_inner!{
$kept
$ignorance
[$gen_arg]
$prev_cself
[$($rem)*]
}
};
($kept:tt $ignorance:tt $prev_cself:tt [$(,)? $gen_arg:tt > $($rem:tt)*]) => {
$crate::__impl_to_panicvals_step_bbb_inner!{
$kept
$ignorance
[$gen_arg]
$prev_cself
[> $($rem)*]
}
};
($kept:tt $ignorance:tt $prev_cself:tt [$(,)? $ty_arg:ty , $($rem:tt)* ]) => {
$crate::__impl_to_panicvals_step_bbb_inner!{
$kept
$ignorance
[$ty_arg]
$prev_cself
[$($rem)*]
}
};
($kept:tt $ignorance:tt $prev_cself:tt [$(,)? $ty_arg:ty > $($rem:tt)*]) => {
$crate::__impl_to_panicvals_step_bbb_inner!{
$kept
$ignorance
[$ty_arg]
$prev_cself
[> $($rem)*]
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_to_panicvals_step_bbb_inner {
(
$kept:tt
[kept $gp_arg_concrete:tt $($rem_ignorance:tt)*]
[$gen_arg:tt]
[$($prev_cself:tt)*]
$rem:tt
) => {
$crate::__impl_to_panicvals_step_bbb!{
$kept
[$($rem_ignorance)*]
[$($prev_cself)* $gen_arg,]
$rem
}
};
(
$kept:tt
[ignore ($($gp_arg_concrete:tt)*) $($rem_ignorance:tt)*]
$gen_arg:tt
[$($prev_cself:tt)*]
$rem:tt
) => {
$crate::__impl_to_panicvals_step_bbb!{
$kept
[$($rem_ignorance)*]
[$($prev_cself)* $($gp_arg_concrete)*,]
$rem
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_to_panicvals_finish {
(
(
[$($impl_param:tt)*]
$type:ty
[
$(#[pfmt(display_fmt = $display_fmt:expr)])?
$(#[pfmt(panicvals_lower_bound = $__panicvals_lower_bound:expr)])?
$type_kind:ident $type_name:ident
$generics:tt
$type_where_preds:tt
$($to_panicval_impls:tt)*
]
[$(
(
$variant:ident
$delimiter:ident
($field_amount:expr, $($ignore2:tt)*)
=>
$(
$is_last_field:ident
(
($fpati:tt $($ignore3:tt)?),
($fname:tt $($ignore4:tt)?),
$ty:ty
)
)*
)
)*]
)
[ $($where_preds:tt)* ]
$cself:tt
) => {
#[automatically_derived]
impl<$($impl_param)*> $type
where
$($where_preds)*
{
pub const fn to_panicvals(
&self,
mut fmt: $crate::FmtArg,
) -> [$crate::PanicVal<'_>; $crate::__ipm_cself!($type_name $cself)] {
$(
if let $crate::fmt::FmtKind::Display = fmt.fmt_kind {
$display_fmt(self, fmt)
} else
)? {
match self {
$(
$crate::__ipm_pattern!($type_kind $variant{$($fpati: $fname,)* ..}) =>
$crate::__ipm_fmt!{
($crate::__ipm_cself!($type_name $cself))
$delimiter
$variant
fmt
( $($is_last_field ($fname, $ty))* )
},
)*
}
}
}
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ipm_pattern {
(struct $name:ident {$($patterns:tt)*}) => {
$name {$($patterns)*}
};
(enum $name:ident {$($patterns:tt)*}) => {
Self::$name {$($patterns)*}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ipm_fmt {
(
($count:expr) $delimiter:ident $typename:ident $fmt:ident
( $($is_last_field:ident ($fname:ident, $ty:ty))+ )
) => ({
let (open, close) = $crate::fmt::TypeDelim::$delimiter.get_open_and_close();
$crate::__::flatten_panicvals::<{$count}>(&[
&[
$crate::PanicVal::write_str($crate::__::stringify!($typename)),
{
$fmt = $fmt.indent();
open.to_panicval($fmt)
}
],
$(
$crate::__ipm_pv_fmt_field_name!($delimiter $fname),
&$crate::PanicFmt::PROOF
.infer($fname)
.coerce($fname)
.to_panicvals($fmt),
&$crate::__ipm_pv_comma!($is_last_field)
.to_panicvals($fmt),
)*
&[
{
$fmt = $fmt.unindent();
close.to_panicval($fmt)
}
],
])
});
(
($count:expr) $delimiter:ident $typename:ident $fmt:ident
()
) => {
$crate::__::flatten_panicvals::<{$count}>(&[
&[$crate::PanicVal::write_str($crate::__::stringify!($typename))]
])
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ipm_pv_fmt_field_name {
(Tupled $field_name:ident) => {
&[]
};
(Braced $field_name:ident) => {
&[$crate::PanicVal::write_str($crate::__::concat!(
$crate::__::stringify!($field_name),
": "
))]
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ipm_pv_comma {
(prefix) => {
$crate::fmt::COMMA_SEP
};
(last) => {
$crate::fmt::COMMA_TERM
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ipm_cself {
($type_name:ident [$($cself:tt)*]) => {
<$type_name<$($cself)*> as $crate::PanicFmt>::PV_COUNT
};
}