Struct codespan_reporting::diagnostic::Diagnostic
source · pub struct Diagnostic<FileId> {
pub severity: Severity,
pub code: Option<String>,
pub message: String,
pub labels: Vec<Label<FileId>>,
pub notes: Vec<String>,
}
Expand description
Represents a diagnostic message that can provide information like errors and warnings to the user.
The position of a Diagnostic is considered to be the position of the Label
that has the earliest starting position and has the highest style which appears in all the labels of the diagnostic.
Fields§
§severity: Severity
The overall severity of the diagnostic
code: Option<String>
An optional code that identifies this diagnostic.
message: String
The main message associated with this diagnostic.
These should not include line breaks, and in order support the ‘short’ diagnostic display mod, the message should be specific enough to make sense on its own, without additional context provided by labels and notes.
labels: Vec<Label<FileId>>
Source labels that describe the cause of the diagnostic. The order of the labels inside the vector does not have any meaning. The labels are always arranged in the order they appear in the source code.
notes: Vec<String>
Notes that are associated with the primary cause of the diagnostic. These can include line breaks for improved formatting.
Implementations§
source§impl<FileId> Diagnostic<FileId>
impl<FileId> Diagnostic<FileId>
sourcepub fn new(severity: Severity) -> Diagnostic<FileId>
pub fn new(severity: Severity) -> Diagnostic<FileId>
Create a new diagnostic.
sourcepub fn bug() -> Diagnostic<FileId>
pub fn bug() -> Diagnostic<FileId>
Create a new diagnostic with a severity of Severity::Bug
.
sourcepub fn error() -> Diagnostic<FileId>
pub fn error() -> Diagnostic<FileId>
Create a new diagnostic with a severity of Severity::Error
.
sourcepub fn warning() -> Diagnostic<FileId>
pub fn warning() -> Diagnostic<FileId>
Create a new diagnostic with a severity of Severity::Warning
.
sourcepub fn note() -> Diagnostic<FileId>
pub fn note() -> Diagnostic<FileId>
Create a new diagnostic with a severity of Severity::Note
.
sourcepub fn help() -> Diagnostic<FileId>
pub fn help() -> Diagnostic<FileId>
Create a new diagnostic with a severity of Severity::Help
.
sourcepub fn with_code(self, code: impl Into<String>) -> Diagnostic<FileId>
pub fn with_code(self, code: impl Into<String>) -> Diagnostic<FileId>
Set the error code of the diagnostic.
sourcepub fn with_message(self, message: impl Into<String>) -> Diagnostic<FileId>
pub fn with_message(self, message: impl Into<String>) -> Diagnostic<FileId>
Set the message of the diagnostic.
sourcepub fn with_labels(self, labels: Vec<Label<FileId>>) -> Diagnostic<FileId>
pub fn with_labels(self, labels: Vec<Label<FileId>>) -> Diagnostic<FileId>
Add some labels to the diagnostic.
sourcepub fn with_notes(self, notes: Vec<String>) -> Diagnostic<FileId>
pub fn with_notes(self, notes: Vec<String>) -> Diagnostic<FileId>
Add some notes to the diagnostic.
Trait Implementations§
source§impl<FileId: Clone> Clone for Diagnostic<FileId>
impl<FileId: Clone> Clone for Diagnostic<FileId>
source§fn clone(&self) -> Diagnostic<FileId>
fn clone(&self) -> Diagnostic<FileId>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<FileId: Debug> Debug for Diagnostic<FileId>
impl<FileId: Debug> Debug for Diagnostic<FileId>
source§impl<FileId: PartialEq> PartialEq for Diagnostic<FileId>
impl<FileId: PartialEq> PartialEq for Diagnostic<FileId>
impl<FileId: Eq> Eq for Diagnostic<FileId>
impl<FileId> StructuralPartialEq for Diagnostic<FileId>
Auto Trait Implementations§
impl<FileId> Freeze for Diagnostic<FileId>
impl<FileId> RefUnwindSafe for Diagnostic<FileId>where
FileId: RefUnwindSafe,
impl<FileId> Send for Diagnostic<FileId>where
FileId: Send,
impl<FileId> Sync for Diagnostic<FileId>where
FileId: Sync,
impl<FileId> Unpin for Diagnostic<FileId>where
FileId: Unpin,
impl<FileId> UnwindSafe for Diagnostic<FileId>where
FileId: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)