pub enum Severity {
Error,
Warning,
Note,
}Expand description
The seriousness of a Diagnostic.
A driver runs a program through a chain of stages, and each stage reports
what it found by emitting diagnostics into the Session.
The severity is what tells the driver — and the person reading the output —
whether a diagnostic is a hard failure that should stop compilation, a
heads-up that something looks wrong, or a neutral remark that adds context.
Only Error counts toward
Session::error_count; a warning or a note is
recorded and rendered but never trips
Session::abort_if_errors. Ordering the
variants by seriousness — error first — mirrors that: Error < Warning < Note
is not the intent, so the type intentionally does not derive Ord. Compare
with is_error instead of relying on a numeric rank.
Variants§
Error
A hard failure. Counts toward the session’s error total and makes
Session::abort_if_errors stop the
build.
Warning
Something suspicious that does not by itself stop compilation.
Note
Neutral context attached to the output — a hint, a location, a reminder.
Implementations§
Source§impl Severity
impl Severity
Sourcepub fn is_error(self) -> bool
pub fn is_error(self) -> bool
Whether this is Severity::Error — the only severity that counts as a
build failure.
§Examples
use driver_lang::Severity;
assert!(Severity::Error.is_error());
assert!(!Severity::Warning.is_error());
assert!(!Severity::Note.is_error());Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The lowercase label used when a diagnostic is rendered
("error", "warning", "note").
§Examples
use driver_lang::Severity;
assert_eq!(Severity::Error.as_str(), "error");
assert_eq!(Severity::Warning.as_str(), "warning");
assert_eq!(Severity::Note.as_str(), "note");