mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Implement Display
for macro expansion errors
This commit is contained in:
parent
db061fb274
commit
2c85db8eb6
2 changed files with 27 additions and 0 deletions
|
@ -240,6 +240,17 @@ pub enum ExpansionError {
|
|||
ExpansionError(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for ExpansionError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
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::ExpansionError(e) => write!(f, "proc macro returned error: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TokenExpander: Debug + Send + Sync + RefUnwindSafe {
|
||||
fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>)
|
||||
-> Result<Subtree, ExpansionError>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue