pub struct Diagnostic {
pub severity: Severity,
pub message: String,
pub span: Span,
pub labels: Vec<Label>,
pub notes: Vec<String>,
pub help: Vec<String>,
pub code: Option<&'static str>,
pub fixes: Vec<Fix>,
}Fields§
§severity: Severity§message: String§span: Span§labels: Vec<Label>§notes: Vec<String>§help: Vec<String>Suggestions for fixing the problem, shown as = help: ....
code: Option<&'static str>A stable identifier for the kind of problem, e.g. unused_variables.
fixes: Vec<Fix>Edits an editor can apply to fix the problem.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Source§impl Diagnostic
impl Diagnostic
pub fn error(message: impl Into<String>, span: Span) -> Self
pub fn warning(message: impl Into<String>, span: Span) -> Self
pub fn note(message: impl Into<String>, span: Span) -> Self
pub fn with_label(self, span: Span, message: impl Into<String>) -> Self
pub fn with_note(self, note: impl Into<String>) -> Self
pub fn with_help(self, help: impl Into<String>) -> Self
pub fn with_code(self, code: &'static str) -> Self
Sourcepub fn with_fix(
self,
title: impl Into<String>,
span: Span,
text: impl Into<String>,
) -> Self
pub fn with_fix( self, title: impl Into<String>, span: Span, text: impl Into<String>, ) -> Self
Adds a fix that replaces span with text.
Sourcepub fn render_plain(&self, file_name: &str, source: &str) -> String
pub fn render_plain(&self, file_name: &str, source: &str) -> String
Plain one-line rendering: file:line:col: error: message.
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 Diagnosticwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Label>: Freeze,
PhantomData<String>: Freeze,
&'static str: Freeze,
PhantomData<Fix>: Freeze,
impl Move for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnosticwhere
RawVecInner: Sync,
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnosticwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Label>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
&'static str: UnsafeUnpin,
PhantomData<Fix>: UnsafeUnpin,
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