pub struct RawDiagnostic<FileId> {
    pub severity: Severity,
    pub code: Option<String>,
    pub message: String,
    pub labels: Vec<Label<FileId>, Global>,
    pub notes: Vec<String, Global>,
}
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>, Global>

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, Global>

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>

source

pub fn new(severity: Severity) -> Diagnostic<FileId>

Create a new diagnostic.

source

pub fn bug() -> Diagnostic<FileId>

Create a new diagnostic with a severity of Severity::Bug.

source

pub fn error() -> Diagnostic<FileId>

Create a new diagnostic with a severity of Severity::Error.

source

pub fn warning() -> Diagnostic<FileId>

Create a new diagnostic with a severity of Severity::Warning.

source

pub fn note() -> Diagnostic<FileId>

Create a new diagnostic with a severity of Severity::Note.

source

pub fn help() -> Diagnostic<FileId>

Create a new diagnostic with a severity of Severity::Help.

source

pub fn with_code(self, code: impl Into<String>) -> Diagnostic<FileId>

Set the error code of the diagnostic.

source

pub fn with_message(self, message: impl Into<String>) -> Diagnostic<FileId>

Set the message of the diagnostic.

source

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

Add some labels to the diagnostic.

source

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

Add some notes to the diagnostic.

Trait Implementations§

source§

impl<FileId> Clone for Diagnostic<FileId>where
    FileId: Clone,

source§

fn clone(&self) -> Diagnostic<FileId>

Returns a copy 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<FileId> Debug for Diagnostic<FileId>where
    FileId: Debug,

source§

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

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

impl<'de, FileId> Deserialize<'de> for Diagnostic<FileId>where
    FileId: Deserialize<'de>,

source§

fn deserialize<__D>(
    __deserializer: __D
) -> Result<Diagnostic<FileId>, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Diagnostic> for RawDiagnostic<()>

source§

fn from(diag: Diagnostic) -> Self

Converts to this type from the input type.
source§

impl<FileId> PartialEq<Diagnostic<FileId>> for Diagnostic<FileId>where
    FileId: PartialEq<FileId>,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<FileId> Serialize for Diagnostic<FileId>where
    FileId: Serialize,

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<FileId> Eq for Diagnostic<FileId>where
    FileId: Eq,

source§

impl<FileId> StructuralEq for Diagnostic<FileId>

source§

impl<FileId> StructuralPartialEq for Diagnostic<FileId>

Auto Trait Implementations§

§

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> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
    T: Clone,

§

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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere
    T: for<'de> Deserialize<'de>,