pub struct Diagnostic {
pub code: DiagCode,
pub severity: Severity,
pub message: String,
pub primary: Span,
pub labels: Vec<Label>,
pub help: Option<String>,
pub fixes: Vec<Fix>,
}Expand description
One located problem.
labels carries the underline text: the first label whose span equals
Diagnostic::primary is rendered as the primary annotation, every other
label as context. A diagnostic with no matching label still underlines the
primary span, with no text.
Fields§
§code: DiagCodeStable code for this message (see codes).
severity: Severity§message: StringShort summary on the error: line.
primary: SpanWhere the diagnostic points.
labels: Vec<Label>Underline text, primary label included.
help: Option<String>§fixes: Vec<Fix>Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn error(
code: DiagCode,
primary: Span,
message: impl Into<String>,
label: impl Into<String>,
) -> Self
pub fn error( code: DiagCode, primary: Span, message: impl Into<String>, label: impl Into<String>, ) -> Self
An error with a primary span and one label.
Sourcepub fn warning(
code: DiagCode,
primary: Span,
message: impl Into<String>,
label: impl Into<String>,
) -> Self
pub fn warning( code: DiagCode, primary: Span, message: impl Into<String>, label: impl Into<String>, ) -> Self
A warning with a primary span and one label.
Sourcepub fn with_label(self, span: Span, text: impl Into<String>) -> Self
pub fn with_label(self, span: Span, text: impl Into<String>) -> Self
Add a context underline.
Sourcepub fn primary_label(&self) -> Option<&Label>
pub fn primary_label(&self) -> Option<&Label>
The label rendered as the primary annotation, if one matches the primary span exactly.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
impl Eq for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Forget for Diagnostic
impl Freeze for Diagnostic
impl Move 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