Diagnostic

Struct Diagnostic 

Source
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: DiagnosticLevel

The overall severity of the labels

§code: Option<String>

An optional code that identifies this labels.

§message: String

The 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

Source

pub fn new(severity: DiagnosticLevel) -> Diagnostic

Create a new label.

Source

pub fn info() -> Diagnostic

Create a new info label.

Source

pub fn warning() -> Diagnostic

Create a new warning label.

Source

pub fn error() -> Diagnostic

Create a new error label.

Source

pub fn fatal() -> Diagnostic

Create a new fatal label.

Source

pub fn with_code(self, code: impl Display) -> Diagnostic

Set the error code of the labels.

Source

pub fn with_message(self, message: impl Display) -> Diagnostic

Set the message of the labels.

Source

pub fn with_primary( self, file_id: &FileID, range: Range<usize>, message: impl Display, ) -> Diagnostic

Add some labels to the labels.

Source

pub fn with_secondary( self, file_id: &FileID, range: Range<usize>, message: impl Display, ) -> Diagnostic

Add some labels to the labels.

Source

pub fn with_labels(self, labels: Vec<Label>) -> Diagnostic

Add some labels to the labels.

Source

pub fn with_note(self, note: impl Display) -> Diagnostic

Add some notes to the labels.

Source

pub fn with_notes(self, notes: Vec<String>) -> Diagnostic

Add some notes to the labels.

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Diagnostic

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Diagnostic

Source§

fn eq(&self, other: &Diagnostic) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Diagnostic

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Diagnostic

Source§

impl StructuralPartialEq for Diagnostic

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.