pub struct Diagnostic {
pub severity: Severity,
pub message: String,
pub code: Option<String>,
pub labels: Vec<Label>,
pub notes: Vec<String>,
pub suggestions: Vec<Suggestion>,
}Expand description
A diagnostic message with source locations and suggestions.
Fields§
§severity: SeverityThe severity of this diagnostic.
message: StringThe main message.
code: Option<String>An optional error code.
labels: Vec<Label>Labeled spans with messages.
notes: Vec<String>Additional notes.
suggestions: Vec<Suggestion>Suggested fixes.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn bug(message: impl Into<String>) -> Self
pub fn bug(message: impl Into<String>) -> Self
Create a new bug diagnostic (internal compiler error).
Sourcepub fn with_label(self, span: FullSpan, message: impl Into<String>) -> Self
pub fn with_label(self, span: FullSpan, message: impl Into<String>) -> Self
Add a primary label.
Sourcepub fn with_secondary_label(
self,
span: FullSpan,
message: impl Into<String>,
) -> Self
pub fn with_secondary_label( self, span: FullSpan, message: impl Into<String>, ) -> Self
Add a secondary label.
Sourcepub fn with_suggestion(self, suggestion: Suggestion) -> Self
pub fn with_suggestion(self, suggestion: Suggestion) -> Self
Add a suggestion.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl IntoDiagnostic for Diagnostic
impl IntoDiagnostic for Diagnostic
Source§fn into_diagnostic(self) -> Diagnostic
fn into_diagnostic(self) -> Diagnostic
Convert into a 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