ExpandError::BindingError(e) => f.write_str(e),
ExpandError::ConversionError => f.write_str("could not convert tokens"),
ExpandError::InvalidRepeat => f.write_str("invalid repeat expression"),
- ExpandError::ProcMacroError(e) => write!(f, "{}", e),
+ ExpandError::ProcMacroError(e) => e.fmt(f),
ExpandError::Other(e) => f.write_str(e),
}
}
//! `tt` crate defines a `TokenTree` data structure: this is the interface (both
//! input and output) of macros. It closely mirrors `proc_macro` crate's
//! `TokenTree`.
-use std::{
- fmt::{self, Debug},
- panic::RefUnwindSafe,
-};
+use std::{fmt, panic::RefUnwindSafe};
use stdx::impl_from;
Ok(())
}
-impl Debug for Subtree {
+impl fmt::Debug for Subtree {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
print_debug_subtree(f, self, 0)
}
match self {
ExpansionError::IOError(e) => write!(f, "I/O error: {}", e),
ExpansionError::JsonError(e) => write!(f, "JSON decoding error: {}", e),
- ExpansionError::Unknown(e) => write!(f, "{}", e),
+ ExpansionError::Unknown(e) => e.fmt(f),
ExpansionError::ExpansionError(e) => write!(f, "proc macro returned error: {}", e),
}
}
}
-pub trait TokenExpander: Debug + Send + Sync + RefUnwindSafe {
+pub trait TokenExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>)
-> Result<Subtree, ExpansionError>;
}