Skip to main content

crisp_diagnostics/
lib.rs

1//! Diagnostic reporting against Crisp source spans.
2
3mod format;
4
5use crisp_ast::Span;
6use thiserror::Error;
7
8pub use format::{
9    FormattedDiagnostic, format_diagnostic, format_diagnostic_at, format_ownership_contradiction,
10    format_type_mismatch, format_unresolved_name, from_diagnostic,
11};
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum Severity {
15    Error,
16    Warning,
17    Note,
18}
19
20#[derive(Debug, Clone)]
21pub struct Diagnostic {
22    pub code: String,
23    pub message: String,
24    pub span: Span,
25    pub severity: Severity,
26    pub notes: Vec<String>,
27}
28
29#[derive(Debug, Error)]
30pub enum CompilerError {
31    #[error("[{code}] {message}")]
32    User { code: String, message: String },
33    #[error("internal compiler error: generated Rust failed to compile — crisp bug")]
34    InternalIce,
35}
36
37pub struct DiagnosticSink {
38    pub diagnostics: Vec<Diagnostic>,
39}