summaryrefslogtreecommitdiff
path: root/src/diagnostic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diagnostic.rs')
-rw-r--r--src/diagnostic.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/diagnostic.rs b/src/diagnostic.rs
index 1bf9f42f..2548e1d5 100644
--- a/src/diagnostic.rs
+++ b/src/diagnostic.rs
@@ -4,6 +4,8 @@
//! layout on a best effort process, generating diagnostics for incorrect
//! things.
+use std::fmt::{self, Display, Formatter};
+
/// A diagnostic that arose in parsing or layouting.
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
@@ -30,6 +32,15 @@ impl Diagnostic {
}
}
+impl Display for Level {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ f.pad(match self {
+ Self::Warning => "warning",
+ Self::Error => "error",
+ })
+ }
+}
+
/// Construct a diagnostic with `Error` level.
///
/// ```