pub struct Diagnostic {
pub severity: Severity,
pub message: String,
pub file: Option<String>,
pub line: Option<u32>,
pub column: Option<u32>,
pub category: Option<String>,
pub fix_its: Vec<String>,
pub snippet: Option<String>,
pub note: Option<String>,
pub help: Option<String>,
}Expand description
A structured diagnostic extracted from the C parser (clang-sys).
Contains source location, code snippet, categorized explanation, and actionable fix suggestion, formatted in rustc-style output.
Fields§
§severity: SeveritySeverity: Note, Warning, Error, Fatal
message: StringError message from clang (e.g. “expected ‘)’”)
file: Option<String>Source file path
line: Option<u32>1-based line number
column: Option<u32>1-based column number
category: Option<String>Clang diagnostic category (e.g. “Parse Issue”)
fix_its: Vec<String>Suggested fixes from clang fix-its
snippet: Option<String>3-line code snippet with caret indicator
note: Option<String>Explanatory note (WHY it failed)
help: Option<String>Actionable help (HOW to fix)
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(severity: Severity, message: impl Into<String>) -> Self
pub fn new(severity: Severity, message: impl Into<String>) -> Self
Create a new diagnostic with the given severity and message.
Sourcepub fn error_category(&self) -> ErrorCategory
pub fn error_category(&self) -> ErrorCategory
Infer the error category from the clang category or message content.
Sourcepub fn build_snippet(
source: &str,
line: u32,
column: Option<u32>,
) -> Option<String>
pub fn build_snippet( source: &str, line: u32, column: Option<u32>, ) -> Option<String>
Build a 3-line code snippet with a caret pointing at the error column.
Sourcepub fn infer_note_and_help(&mut self)
pub fn infer_note_and_help(&mut self)
Populate note and help based on common C error patterns.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more