macro_rules! sq_err {
[ return $($tt:tt)* ] => {
return sq_err! {
$($tt)*
}
};
[ break $($tt:tt)* ] => {
break sq_err! {
$($tt)*
}
};
[ [$span:expr]: $err:expr $(,)? ] => {
quote::quote_spanned! {
$span =>
compile_error!($err);
}.into()
};
[ [$span:expr]: $($err:tt)+ ] => {{
$crate::trees::__sq_err_format!(
@let_block: in[ $($err)+ ]
);
$crate::trees::__sq_err_format!(
quote::quote_spanned! {
$span =>
compile_error!(
concat!( in[ $($err)+ ] args[] )
)
}
)
}};
}
macro_rules! __sq_err_format {
[
@let_block:
in[ # {$n:ident :?} $($all:tt)* ]
] => {
let $n = format!("{:?}", $n);
$crate::trees::__sq_err_format! {
@let_block:
in [ $($all)* ]
}
};
[
@let_block:
in[ # {$n:ident} $($all:tt)* ]
] => {
let $n = format!("{}", $n);
$crate::trees::__sq_err_format! {
@let_block:
in [ $($all)* ]
}
};
[
@let_block:
in[ $_t:tt $($all:tt)* ]
] => {
$crate::trees::__sq_err_format! {
@let_block:
in [ $($all)* ]
}
};
[ @let_block:
in[]
] => {};
[ quote::quote_spanned! {
$span:expr =>
compile_error!(concat!(
in[ # {$n:ident :?} $($all:tt)* ]
args[ $($args:tt)* ]
))
}
] => {
$crate::trees::__sq_err_format! {
quote::quote_spanned! {
$span =>
compile_error!(concat!(
in[ $($all)* ]
args[ $($args)* # $n ]
))
}
}
};
[ quote::quote_spanned! {
$span:expr =>
compile_error!(concat!(
in[ # {$n:ident} $($all:tt)* ]
args[ $($args:tt)* ]
))
}
] => {
$crate::trees::__sq_err_format! {
quote::quote_spanned! {
$span =>
compile_error!(concat!(
in[ $($all)* ]
args[ $($args)* # $n ]
))
}
}
};
[
quote::quote_spanned! {
$span:expr =>
compile_error!(concat!(
in[ $t:tt $($all:tt)* ]
args[ $($args:tt)* ]
))
}
] => {
$crate::trees::__sq_err_format! {
quote::quote_spanned! {
$span =>
compile_error!(concat!(
in[ $($all)* ]
args[ $($args)* $t ]
))
}
}
};
[ quote::quote_spanned! {
$span:expr =>
compile_error!(concat!(
in[ ]
args[ $($args:tt)* ]
))
}
] => {
quote::quote_spanned! {
$span =>
compile_error!(
concat!( $($args)* )
);
}.into()
};
}