InFlightDiagnostic

Struct InFlightDiagnostic 

Source
pub struct InFlightDiagnostic<'h> { /* private fields */ }
Expand description

Constructs an in-flight diagnostic using the builder pattern

Implementations§

Source§

impl<'h> InFlightDiagnostic<'h>

Source

pub fn severity(&self) -> Severity

Returns the severity level of this diagnostic

Source

pub fn verbose(&self) -> bool

Returns whether this diagnostic should be generated with verbose detail. Intended to be used when building diagnostics in-flight by formatting functions which do not know what the current diagnostic configuration is

Source

pub fn set_source_file(self, filename: impl Into<FileName>) -> Self

Sets the current source file to which this diagnostic applies

Source

pub fn with_message(self, message: impl ToString) -> Self

Sets the diagnostic message to message

Source

pub fn with_primary_span(self, span: SourceSpan) -> Self

Adds a primary label for span to this diagnostic, with no label message.

Source

pub fn with_primary_label( self, span: SourceSpan, message: impl ToString, ) -> Self

Adds a primary label for span to this diagnostic, with the given message

A primary label is one which should be rendered as the relevant source code at which a diagnostic originates. Secondary labels are used for related items involved in the diagnostic.

Source

pub fn with_secondary_label( self, span: SourceSpan, message: impl ToString, ) -> Self

Adds a secondary label for span to this diagnostic, with the given message

A secondary label is used to point out related items in the source code which are relevant to the diagnostic, but which are not themselves the point at which the diagnostic originates.

Source

pub fn with_primary_label_line_and_col( self, line: u32, column: u32, message: Option<String>, ) -> Self

Like with_primary_label, but rather than a SourceSpan, it accepts a line and column number, which will be mapped to an appropriate span by the CodeMap.

Source

pub fn with_label( self, style: LabelStyle, filename: Option<FileName>, line: u32, column: u32, message: Option<String>, ) -> Self

This is a lower-level function for adding labels to diagnostics, providing full control over its style, content, and location in the source code.

Source

pub fn with_note(self, note: impl ToString) -> Self

Adds a note to the diagnostic

Notes are used for explaining general concepts or suggestions related to a diagnostic, and are not associated with any particular source location. They are always rendered after the other diagnostic content.

Source

pub fn add_note(&mut self, note: impl ToString)

Like with_note, but is intended for use cases where the fluent/builder pattern used here is cumbersome.

Source

pub fn take(self) -> Diagnostic

Consume this InFlightDiagnostic and extract the underlying Diagnostic

Source

pub fn emit(self)

Emit the underlying Diagnostic via the [DiagnosticHandler]

Auto Trait Implementations§

§

impl<'h> Freeze for InFlightDiagnostic<'h>

§

impl<'h> !RefUnwindSafe for InFlightDiagnostic<'h>

§

impl<'h> Send for InFlightDiagnostic<'h>

§

impl<'h> Sync for InFlightDiagnostic<'h>

§

impl<'h> Unpin for InFlightDiagnostic<'h>

§

impl<'h> !UnwindSafe for InFlightDiagnostic<'h>

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