summaryrefslogtreecommitdiff
path: root/src/diag.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diag.rs')
-rw-r--r--src/diag.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/diag.rs b/src/diag.rs
index 6249a7cd..f0455310 100644
--- a/src/diag.rs
+++ b/src/diag.rs
@@ -1,5 +1,7 @@
//! Diagnostics.
+use std::fmt::{self, Display, Formatter};
+
use serde::{Deserialize, Serialize};
use crate::syntax::{Span, Spanned};
@@ -59,6 +61,18 @@ pub enum Tracepoint {
Import,
}
+impl Display for Tracepoint {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ Tracepoint::Call(Some(name)) => {
+ write!(f, "error occured in this call of function `{}`", name)
+ }
+ Tracepoint::Call(None) => f.pad("error occured in this function call"),
+ Tracepoint::Import => f.pad("error occured while importing this module"),
+ }
+ }
+}
+
/// Convert a [`StrResult`] to a [`TypResult`] by adding span information.
pub trait At<T> {
/// Add the span information.