use std::fmt;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiagnosticCode {
pub code: String,
pub explanation: Option<String>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiagnosticSpanLine {
pub text: String,
pub highlight_start: usize,
pub highlight_end: usize,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiagnosticSpanMacroExpansion {
pub span: DiagnosticSpan,
pub macro_decl_name: String,
pub def_site_span: Option<DiagnosticSpan>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiagnosticSpan {
pub file_name: String,
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,
pub text: Vec<DiagnosticSpanLine>,
pub label: Option<String>,
pub suggested_replacement: Option<String>,
pub suggestion_applicability: Option<Applicability>,
pub expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Applicability {
MachineApplicable,
HasPlaceholders,
MaybeIncorrect,
Unspecified,
#[doc(hidden)]
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DiagnosticLevel {
#[serde(rename = "error: internal compiler error")]
Ice,
Error,
Warning,
Note,
Help,
#[doc(hidden)]
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Diagnostic {
pub message: String,
pub code: Option<DiagnosticCode>,
pub level: DiagnosticLevel,
pub spans: Vec<DiagnosticSpan>,
pub children: Vec<Diagnostic>,
pub rendered: Option<String>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}
impl fmt::Display for Diagnostic {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(ref rendered) = self.rendered {
f.write_str(rendered)?;
} else {
f.write_str("cargo didn't render this message")?;
}
Ok(())
}
}