1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Diagnostics produced by the planner — port of the subset of `diagnostics.ts`
//! that `Plan` needs / `Diagnostics.java`.
use crate::span::Span;
/// Diagnostic severity. Only `Error` is constructed today.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Severity {
Error,
Warning,
Info,
}
/// The closed set of diagnostic codes the planner produces. `Ord` follows the
/// Java enum's declaration order (ordinal), matching its sort semantics.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum DiagnosticCode {
AmbiguousMatch,
ErrorFenceWithoutStep,
Drift,
}
/// One diagnostic: its code, severity, and the source span it points at.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Diagnostic {
pub code: DiagnosticCode,
pub severity: Severity,
pub span: Span,
}
/// Builds an `ambiguous-match` diagnostic pointing at `span`.
pub fn ambiguous_match(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::AmbiguousMatch,
severity: Severity::Error,
span,
}
}
/// Builds an `error-fence-without-step` diagnostic pointing at `span`.
pub fn error_fence_without_step(span: Span) -> Diagnostic {
Diagnostic {
code: DiagnosticCode::ErrorFenceWithoutStep,
severity: Severity::Error,
span,
}
}