use proc_macro2::TokenTree;
impl crate::Debug for proc_macro2::Span {
fn fmt(&self, f: &mut crate::Formatter) {
let start = self.start();
let end = self.end();
let start_line = start.line;
let end_line = end.line;
let start_col = start.column;
let end_col = end.column;
f.debug_tuple("Span")
.field(&format_args!(
"{start_line}:{start_col}: {end_line}:{end_col}"
))
.finish()
}
}
impl crate::Debug for proc_macro2::TokenStream {
fn fmt(&self, f: &mut crate::Formatter) {
f.debug_named_list("TokenStream")
.entries(self.clone())
.finish()
}
}
impl crate::Debug for proc_macro2::Ident {
fn fmt(&self, f: &mut crate::Formatter) {
f.debug_struct("Ident")
.field("sym", &self.to_string())
.field("span", &self.span())
.finish();
}
}
impl crate::Debug for proc_macro2::TokenTree {
fn fmt(&self, f: &mut crate::Formatter) {
match self {
TokenTree::Group(t) => t.fmt(f),
TokenTree::Ident(t) => t.fmt(f),
TokenTree::Punct(t) => t.fmt(f),
TokenTree::Literal(t) => t.fmt(f),
}
}
}
impl crate::Debug for proc_macro2::Literal {
fn fmt(&self, f: &mut crate::Formatter) {
f.debug_struct("Literal")
.field("lit", &format_args!("{}", self))
.field("span", &self.span())
.finish()
}
}
impl crate::Debug for proc_macro2::Punct {
fn fmt(&self, f: &mut crate::Formatter) {
f.debug_struct("Punct")
.field("char", &self.as_char())
.field("spacing", &self.spacing())
.field("span", &self.spacing())
.finish()
}
}
impl crate::Debug for proc_macro2::Group {
fn fmt(&self, f: &mut crate::Formatter) {
f.debug_struct("Group")
.field("delimiter", &self.delimiter())
.field("stream", &self.stream())
.field("span", &self.span())
.finish();
}
}