smelt_stdlib/diagnostics.rs
1//! Diagnostics for recognized but unsupported standard-library forms.
2
3use crate::RuleId;
4
5/// Unsupported source shape for a known standard-library rule.
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum UnsupportedForm {
9 /// The call used an unsupported argument count.
10 ArgumentCount,
11 /// The call used keyword/named arguments that are not modeled yet.
12 KeywordArguments,
13 /// The call used unsupported argument types.
14 ArgumentTypes,
15 /// The call omitted required type context.
16 MissingTypeContext,
17}
18
19/// Diagnostic metadata for a known standard-library API that cannot lower yet.
20#[derive(Clone, Copy, Debug, Eq, PartialEq)]
21#[non_exhaustive]
22pub struct StdlibDiagnostic {
23 /// Rule whose API spelling was recognized.
24 pub rule: RuleId,
25 /// Unsupported source shape.
26 pub form: UnsupportedForm,
27 /// Stable user-facing diagnostic message.
28 pub message: &'static str,
29}
30
31impl StdlibDiagnostic {
32 /// Create a diagnostic for an unsupported known API form.
33 #[must_use]
34 pub const fn unsupported(rule: RuleId, form: UnsupportedForm, message: &'static str) -> Self {
35 Self {
36 rule,
37 form,
38 message,
39 }
40 }
41}