Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/lib.rs')
-rw-r--r--crates/hir-expand/src/lib.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 2ee598dfbf..5aafe6db52 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -28,6 +28,7 @@ use rustc_hash::FxHashMap;
use stdx::TupleExt;
use triomphe::Arc;
+use core::fmt;
use std::hash::Hash;
use base_db::{ra_salsa::InternValueTrivial, CrateId};
@@ -147,6 +148,10 @@ impl ExpandError {
pub fn span(&self) -> Span {
self.inner.1
}
+
+ pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
+ self.inner.0.render_to_string(db)
+ }
}
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
@@ -164,18 +169,18 @@ pub enum ExpandErrorKind {
ProcMacroPanic(Box<str>),
}
-impl ExpandError {
- pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
- self.inner.0.render_to_string(db)
- }
-}
-
pub struct RenderedExpandError {
pub message: String,
pub error: bool,
pub kind: &'static str,
}
+impl fmt::Display for RenderedExpandError {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.message)
+ }
+}
+
impl RenderedExpandError {
const GENERAL_KIND: &str = "macro-error";
}