pub struct Diagnostic {
pub severity: Severity,
pub code: String,
pub message: String,
pub labels: Vec<Label>,
pub notes: Vec<String>,
pub fixes: Vec<Fix>,
}Expand description
A single compiler diagnostic shown to the user.
Every diagnostic has an error code (e.g. E0042), a title, at least one
source span, and an optional suggestion.
Fields§
§severity: Severity§code: String§message: String§labels: Vec<Label>§notes: Vec<String>§fixes: Vec<Fix>Suggested changes, shown as help: lines and offered as quick
fixes (spec 3.4b §3).
Implementations§
Source§impl Diagnostic
impl Diagnostic
pub fn error(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn warning(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn with_label( self, span: Span, message: impl Into<String>, primary: bool, ) -> Self
pub fn with_primary_label(self, span: Span, message: impl Into<String>) -> Self
pub fn with_secondary_label( self, span: Span, message: impl Into<String>, ) -> Self
pub fn with_note(self, note: impl Into<String>) -> Self
pub fn with_fix(self, fix: Fix) -> Self
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more