pub struct Diagnostic {
pub severity: DiagnosticLevel,
pub code: Option<String>,
pub message: String,
pub labels: Vec<Label>,
pub notes: Vec<String>,
}Expand description
Represents a labels 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 labels.
Fields§
§severity: DiagnosticLevelThe overall severity of the labels
code: Option<String>An optional code that identifies this labels.
message: StringThe main message associated with this labels.
These should not include line breaks, and in order support the ‘short’ labels 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>Source labels that describe the cause of the labels. 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 labels. These can include line breaks for improved formatting.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(severity: DiagnosticLevel) -> Diagnostic
pub fn new(severity: DiagnosticLevel) -> Diagnostic
Create a new label.
Sourcepub fn info() -> Diagnostic
pub fn info() -> Diagnostic
Create a new info label.
Sourcepub fn warning() -> Diagnostic
pub fn warning() -> Diagnostic
Create a new warning label.
Sourcepub fn error() -> Diagnostic
pub fn error() -> Diagnostic
Create a new error label.
Sourcepub fn fatal() -> Diagnostic
pub fn fatal() -> Diagnostic
Create a new fatal label.
Sourcepub fn with_code(self, code: impl Display) -> Diagnostic
pub fn with_code(self, code: impl Display) -> Diagnostic
Set the error code of the labels.
Sourcepub fn with_message(self, message: impl Display) -> Diagnostic
pub fn with_message(self, message: impl Display) -> Diagnostic
Set the message of the labels.
Sourcepub fn with_primary(
self,
file_id: &FileID,
range: Range<usize>,
message: impl Display,
) -> Diagnostic
pub fn with_primary( self, file_id: &FileID, range: Range<usize>, message: impl Display, ) -> Diagnostic
Add some labels to the labels.
Sourcepub fn with_secondary(
self,
file_id: &FileID,
range: Range<usize>,
message: impl Display,
) -> Diagnostic
pub fn with_secondary( self, file_id: &FileID, range: Range<usize>, message: impl Display, ) -> Diagnostic
Add some labels to the labels.
Sourcepub fn with_labels(self, labels: Vec<Label>) -> Diagnostic
pub fn with_labels(self, labels: Vec<Label>) -> Diagnostic
Add some labels to the labels.
Sourcepub fn with_note(self, note: impl Display) -> Diagnostic
pub fn with_note(self, note: impl Display) -> Diagnostic
Add some notes to the labels.
Sourcepub fn with_notes(self, notes: Vec<String>) -> Diagnostic
pub fn with_notes(self, notes: Vec<String>) -> Diagnostic
Add some notes to the labels.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more