summaryrefslogtreecommitdiff
path: root/src/diag.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-09-29 00:10:39 +0200
committerLaurenz <laurmaedje@gmail.com>2021-09-29 00:10:39 +0200
commit989d344d3dc2e08ec2ed5025b202e464a5b29d2c (patch)
tree998fc65fe8e836b51658476a7af1ec77009dd922 /src/diag.rs
parenta0065eef86685223a1bbb2f586036f7df5b36349 (diff)
Implement `Display` for `Tracepoint`
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.