Skip to main content

Errors

Struct Errors 

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

The diagnostics a pass produced, and the limit on how many it will produce.

Implementations§

Source§

impl Errors

Source

pub fn new(limit: usize) -> Self

A sink that stops after limit errors, or that never stops when limit is zero.

Source

pub fn push(&mut self, diagnostic: Diagnostic)

Records a diagnostic.

Once the limit is reached nothing more is recorded, warnings included. The pass is about to stop and a warning arriving after the note that says so reads as though the compiler carried on regardless.

Source

pub fn push_unless(&mut self, suppressed: bool, diagnostic: Diagnostic)

Records a diagnostic unless suppressed says the node it is about is already poisoned.

Every pass that recovers leaves a poisoned node behind, and a message about such a node is not reported, which is what actually stops one error becoming twenty. What counts as poisoned is a fact about a tree rather than about a diagnostic, so the caller answers the question and this only honours the answer.

The suppression is deliberately shallow: the question is whether the node the message is about is itself poisoned, not whether anything underneath it is. A poisoned operand makes its parent poisoned at the point the parent is built, so the answer propagates through the tree rather than through a walk of it, and a walk would make reporting an error cost the size of the subtree.

Source

pub fn stopped(&self) -> bool

Whether the pass should stop, because it has reported as many errors as it will.

Source

pub fn errors(&self) -> usize

How many errors have been reported. Warnings and notes are not counted.

Source

pub fn is_empty(&self) -> bool

Whether anything was reported at all.

Source

pub fn len(&self) -> usize

How many diagnostics were reported, of every severity.

Source

pub fn diagnostics(&self) -> &[Diagnostic]

What has been reported so far, in the order it was reported.

For a caller that wants to look at the diagnostics and carry on, which is what a test does and what a pass that reports at the end of each function will do.

Source

pub fn finish(self) -> Vec<Diagnostic>

What was reported, in the order it was reported.

Trait Implementations§

Source§

impl Debug for Errors

Source§

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

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

impl Default for Errors

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.