use std::borrow;
use std::path;
type CowPath<'a> = borrow::Cow<'a, path::Path>;
type CowStr<'a> = borrow::Cow<'a, str>;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct DiagnosticCode<'a> {
#[serde(borrow)]
pub code: CowStr<'a>,
#[serde(borrow)]
pub explanation: Option<CowStr<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct DiagnosticSpanLine<'a> {
#[serde(borrow)]
pub text: CowStr<'a>,
pub highlight_start: usize,
pub highlight_end: usize,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct DiagnosticSpanMacroExpansion<'a> {
#[serde(borrow)]
pub span: DiagnosticSpan<'a>,
#[serde(borrow)]
pub macro_decl_name: CowStr<'a>,
#[serde(borrow)]
pub def_site_span: Option<DiagnosticSpan<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct DiagnosticSpan<'a> {
#[serde(borrow)]
pub file_name: CowPath<'a>,
pub byte_start: u32,
pub byte_end: u32,
pub line_start: usize,
pub line_end: usize,
pub column_start: usize,
pub column_end: usize,
pub is_primary: bool,
#[serde(borrow)]
pub text: Vec<DiagnosticSpanLine<'a>>,
#[serde(borrow)]
pub label: Option<CowStr<'a>>,
#[serde(borrow)]
pub suggested_replacement: Option<CowStr<'a>>,
pub suggestion_applicability: Option<Applicability>,
#[serde(borrow)]
pub expansion: Option<Box<DiagnosticSpanMacroExpansion<'a>>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Applicability {
MachineApplicable,
HasPlaceholders,
MaybeIncorrect,
Unspecified,
#[cfg(not(feature = "strict_unstable"))]
#[doc(hidden)]
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct Diagnostic<'a> {
#[serde(borrow, rename = "$message_type")]
pub message_type: Option<CowStr<'a>>,
#[serde(borrow)]
pub message: CowStr<'a>,
#[serde(borrow)]
pub code: Option<DiagnosticCode<'a>>,
pub level: DiagnosticLevel,
#[serde(borrow)]
pub spans: Vec<DiagnosticSpan<'a>>,
#[serde(borrow)]
pub children: Vec<Diagnostic<'a>>,
#[serde(borrow)]
pub rendered: Option<CowStr<'a>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DiagnosticLevel {
#[serde(rename = "error: internal compiler error")]
Ice,
Error,
Warning,
Note,
Help,
#[cfg(not(feature = "strict_unstable"))]
#[doc(hidden)]
#[serde(other)]
Unknown,
}