diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-26 15:56:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-26 15:56:58 +0000 |
commit | ad343870ec33d744f0efbd1d9633e62b017b19ea (patch) | |
tree | 6424b095680383a82ad8d4d9f4b239bcdbc9cdcd /crates/tt/src | |
parent | db061fb274ddc9a8820c5f0c90b077c88961d1be (diff) | |
parent | 2c85db8eb6bac4a9106e7373840c0b3d209188a6 (diff) |
Merge #6640
6640: Implement `Display` for macro expansion errors r=jonas-schievink a=jonas-schievink
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/tt/src')
-rw-r--r-- | crates/tt/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs index 20c3f5eab..7c796f564 100644 --- a/crates/tt/src/lib.rs +++ b/crates/tt/src/lib.rs | |||
@@ -240,6 +240,17 @@ pub enum ExpansionError { | |||
240 | ExpansionError(String), | 240 | ExpansionError(String), |
241 | } | 241 | } |
242 | 242 | ||
243 | impl fmt::Display for ExpansionError { | ||
244 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
245 | match self { | ||
246 | ExpansionError::IOError(e) => write!(f, "I/O error: {}", e), | ||
247 | ExpansionError::JsonError(e) => write!(f, "JSON decoding error: {}", e), | ||
248 | ExpansionError::Unknown(e) => write!(f, "{}", e), | ||
249 | ExpansionError::ExpansionError(e) => write!(f, "proc macro returned error: {}", e), | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
243 | pub trait TokenExpander: Debug + Send + Sync + RefUnwindSafe { | 254 | pub trait TokenExpander: Debug + Send + Sync + RefUnwindSafe { |
244 | fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>) | 255 | fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>) |
245 | -> Result<Subtree, ExpansionError>; | 256 | -> Result<Subtree, ExpansionError>; |