Skip to main content

DiagnosticBuilder

Struct DiagnosticBuilder 

Source
pub struct DiagnosticBuilder { /* private fields */ }
Expand description

Builder for Diagnostic. Use this rather than struct literal at emission sites so future schema evolution doesn’t ripple through.

Implementations§

Source§

impl DiagnosticBuilder

Source

pub fn new( diagnostic_id: impl Into<String>, severity: Severity, location: Location, message: impl Into<String>, ) -> Self

Start building a diagnostic with the required minimum (id, severity, location, message).

Source

pub fn expected(self, witness: TypeWitness) -> Self

Attach an expected type witness.

Source

pub fn found(self, witness: TypeWitness) -> Self

Attach a found type witness.

Source

pub fn with_fix(self, fix: SuggestedFix) -> Self

Append a suggested fix.

Source

pub fn context_window(self, window: ContextWindow) -> Self

Attach a context window.

Source

pub fn rule(self, rule: impl Into<String>) -> Self

Attach a rule citation ("ADR-006-§1.1" etc.).

Source

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

Append an auxiliary note.

Source

pub fn build(self) -> Diagnostic

Finalize.

Trait Implementations§

Source§

impl Debug for DiagnosticBuilder

Source§

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

Formats the value using the given formatter. Read more

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