Diagnostic

Struct Diagnostic 

Source
pub struct Diagnostic {
    pub level: Level,
    pub message: Vec<(String, Style)>,
    pub code: Option<String>,
    pub span: MultiSpan,
    pub children: Vec<SubDiagnostic>,
    pub suggestions: Vec<CodeSuggestion>,
}

Fields§

§level: Level§message: Vec<(String, Style)>§code: Option<String>§span: MultiSpan§children: Vec<SubDiagnostic>§suggestions: Vec<CodeSuggestion>

Implementations§

Source§

impl Diagnostic

Source

pub fn new(level: Level, message: &str) -> Self

Source

pub fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self

Source

pub fn cancel(&mut self)

Cancel the diagnostic (a structured diagnostic must either be emitted or cancelled or it will panic when dropped). BEWARE: if this DiagnosticBuilder is an error, then creating it will bump the error count on the Handler and cancelling it won’t undo that. If you want to decrement the error count you should use Handler::cancel.

Source

pub fn cancelled(&self) -> bool

Source

pub fn is_fatal(&self) -> bool

Source

pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self

Add a span/label to be included in the resulting snippet. This is pushed onto the MultiSpan that was created when the diagnostic was first built. If you don’t call this function at all, and you just supplied a Span to create the diagnostic, then the snippet will just include that Span, which is called the primary span.

Source

pub fn note_expected_found( &mut self, label: &dyn Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, ) -> &mut Self

Source

pub fn note_expected_found_extra( &mut self, label: &dyn Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, expected_extra: &dyn Display, found_extra: &dyn Display, ) -> &mut Self

Source

pub fn note(&mut self, msg: &str) -> &mut Self

Source

pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self

Source

pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self

Source

pub fn warn(&mut self, msg: &str) -> &mut Self

Source

pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self

Source

pub fn help(&mut self, msg: &str) -> &mut Self

Source

pub fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self

Source

pub fn span_suggestion( &mut self, sp: Span, msg: &str, suggestion: String, ) -> &mut Self

Prints out a message with a suggested edit of the code.

See diagnostic::CodeSuggestion for more information.

Source

pub fn span_suggestions( &mut self, sp: Span, msg: &str, suggestions: Vec<String>, ) -> &mut Self

Source

pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self

Source

pub fn code(&mut self, s: String) -> &mut Self

Source

pub fn message(&self) -> String

Source

pub fn styled_message(&self) -> &Vec<(String, Style)>

Source

pub fn level(&self) -> Level

Source

pub fn copy_details_not_message(&mut self, from: &Diagnostic)

Used by a lint. Copies over all details but the “main message”.

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

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

impl<'de> Deserialize<'de> for Diagnostic

Source§

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

Deserialize this value from the given Serde deserializer. 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::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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.
Source§

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