use crate::pos::Span;
use std::fmt::Display;
#[derive(Clone, Debug)]
pub struct Diagnostic {
pub kind: DiagnosticKind,
pub span: Span,
}
impl Diagnostic {
pub(crate) fn new(kind: DiagnosticKind, span: Span) -> Self {
Self { kind, span }
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum DiagnosticKind {
SourceTooLong,
}
impl Display for Diagnostic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let message = match &self.kind {
DiagnosticKind::SourceTooLong => "source exceeds the maximum supported size (4 GiB)",
};
write!(f, "{message} at {}..{}", self.span.start, self.span.end)
}
}