-
-
Save danielhenrymantilla/96b1d5b0db83ad7440a306763d2d97d4 to your computer and use it in GitHub Desktop.
Yandros parse_quote! debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credits: Yandros#4299 | |
macro_rules! parse_quote {( | |
$($code:tt)* | |
) => ({ | |
eprintln!("[{}:{}:{}] parse_quote! {{ {} }}", file!(), line!(), column!(), quote!( $($code)* )); | |
::syn::parse_quote!( $($code)* ) | |
})} | |
macro_rules! parse_quote {( | |
$($code:tt)* | |
) => ((|| { | |
fn type_of_some<T> (_: Option<T>) -> &'static str { ::core::any::type_name::<T>() } | |
let target_ty = None; | |
if false { return target_ty.unwrap(); } | |
eprintln!("[{}:{}:{}] parse_quote! {{ {} }} as {}", file!(), line!(), column!(), quote!( $($code)* ), type_of_some(target_ty)); | |
::syn::parse_quote!( $($code)* ) | |
})())} | |
macro_rules! parse_quote {( | |
$($code:tt)* | |
) => ( | |
(|| { | |
fn type_of_some<T> (_: Option<T>) | |
-> &'static str | |
{ | |
::core::any::type_name::<T>() | |
} | |
let target_ty = None; if false { return target_ty.unwrap(); } | |
eprintln!( | |
"[{}:{}:{}:parse_quote!]\n - ty: `{ty}`\n - code: `{code}`", | |
file!(), line!(), column!(), | |
code = ::quote::quote!( $($code)* ), | |
ty = type_of_some(target_ty), | |
); | |
::syn::parse_quote!( $($code)* ) | |
})() | |
)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment