Struct Diagnostic

Source
pub struct Diagnostic {
    pub level: DiagnosticLevel,
    pub labels: Labels,
    pub subdiagnostics: Vec<Subdiagnostic>,
}
Expand description

Something that is wrong in the code.

Fields§

§level: DiagnosticLevel§labels: Labels§subdiagnostics: Vec<Subdiagnostic>

Extra diagnostics that are shown after the main diagnostic.

Implementations§

Source§

impl Diagnostic

Source

fn new( level: DiagnosticLevel, span: impl Into<FullSpan>, message: impl Into<Message>, ) -> Self

Source

pub fn bug(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self

Report that something happened in the compiler that shouldn’t be possible. This signifies that something is wrong with the compiler. It will include a large footer instructing the user to create an issue or otherwise get in touch.

Source

pub fn error(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self

Report that something is wrong with the supplied code.

Source

pub fn level(self, level: DiagnosticLevel) -> Self

Source

pub fn message(self, message: impl Into<Message>) -> Self

Source

pub fn primary_label(self, primary_label: impl Into<Message>) -> Self

Attach a message to the primary label of this diagnostic.

Source

pub fn secondary_label( self, span: impl Into<FullSpan>, message: impl Into<Message>, ) -> Self

Attach a secondary label to this diagnostic.

Source

pub fn note(self, message: impl Into<Message>) -> Self

Attach a simple (one-line) note to this diagnostic.

Source

pub fn add_note(&mut self, message: impl Into<Message>) -> &mut Self

Attach a simple (one-line) note to this diagnostic.

Modifying version of Self::note.

Source

pub fn help(self, message: impl Into<Message>) -> Self

Attach a simple (one-line) help to this diagnostic.

Builder version of Self::add_help.

Source

pub fn add_help(&mut self, message: impl Into<Message>) -> &mut Self

Attach a simple (one-line) help to this diagnostic.

Modifying version of Self::help.

Source

pub fn subdiagnostic(self, subdiagnostic: Subdiagnostic) -> Self

Attach a general subdiagnostic to this diagnostic.

Prefer a more specific convenicence method (see the crate documentation) if you can. This is intended for spanned notes since they need a builder in order to be constructed.

Source

pub fn push_subdiagnostic(&mut self, subdiagnostic: Subdiagnostic) -> &mut Self

Source

pub fn span_suggest( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self

Source

pub fn span_suggest_insert_before( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self

Convenience method to suggest some code that can be inserted directly before some span.

Note that this will be after any preceding whitespace. Use Diagnostic::span_suggest_insert_after if you want the suggestion to insert before preceding whitespace.

Source

pub fn span_suggest_insert_after( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self

Convenience method to suggest some code that can be inserted directly after some span.

Note that this will be before any preceding whitespace. Use Diagnostic::span_suggest_insert_before if you want the suggestion to insert after preceding whitespace.

Source

pub fn span_suggest_replace( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self

Convenience method to suggest some code that can be replaced.

Source

pub fn span_suggest_remove( self, message: impl Into<Message>, span: impl Into<FullSpan>, ) -> Self

Convenience method to suggest some code that can be removed.

Source

pub fn span_suggest_multipart( self, message: impl Into<Message>, parts: SuggestionParts, ) -> Self

Suggest a change that consists of multiple parts.

Source

pub fn push_span_suggest_multipart( &mut self, message: impl Into<Message>, SuggestionParts: SuggestionParts, ) -> &mut Self

Suggest a change that consists of multiple parts, but usable outside of builders.

Source

pub fn type_error( self, expected: String, expected_outer: Option<String>, got: String, got_outer: Option<String>, ) -> Self

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 CompilationError for Diagnostic

Source§

fn report( &self, buffer: &mut Buffer, code: &CodeBundle, diag_handler: &mut DiagHandler, )

Source§

impl Debug for Diagnostic

Source§

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

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 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.