internal: reduce coupling

tt is a data structure, data structures cant' go wrong, they shouldn't
have the knowledge that the world outside of them has all kinds of
errors.
This commit is contained in:
Aleksey Kladov 2021-08-31 19:14:33 +03:00
parent d8a3d6f378
commit 81602f8a5d
6 changed files with 25 additions and 32 deletions

View file

@ -39,17 +39,11 @@ pub enum ExpandError {
UnexpectedToken,
BindingError(String),
ConversionError,
ProcMacroError(tt::ExpansionError),
// FXME: no way mbe should know about proc macros.
UnresolvedProcMacro,
Other(String),
}
impl From<tt::ExpansionError> for ExpandError {
fn from(it: tt::ExpansionError) -> Self {
ExpandError::ProcMacroError(it)
}
}
impl fmt::Display for ExpandError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@ -57,7 +51,6 @@ impl fmt::Display for ExpandError {
ExpandError::UnexpectedToken => f.write_str("unexpected token in input"),
ExpandError::BindingError(e) => f.write_str(e),
ExpandError::ConversionError => f.write_str("could not convert tokens"),
ExpandError::ProcMacroError(e) => e.fmt(f),
ExpandError::UnresolvedProcMacro => f.write_str("unresolved proc macro"),
ExpandError::Other(e) => f.write_str(e),
}