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
impl Errors
Sourcepub fn new(limit: usize) -> Self
pub fn new(limit: usize) -> Self
A sink that stops after limit errors, or that never stops when limit is zero.
Sourcepub fn push(&mut self, diagnostic: Diagnostic)
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.
Sourcepub fn push_unless(&mut self, suppressed: bool, diagnostic: Diagnostic)
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.
Sourcepub fn stopped(&self) -> bool
pub fn stopped(&self) -> bool
Whether the pass should stop, because it has reported as many errors as it will.
Sourcepub fn errors(&self) -> usize
pub fn errors(&self) -> usize
How many errors have been reported. Warnings and notes are not counted.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
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.
Sourcepub fn finish(self) -> Vec<Diagnostic>
pub fn finish(self) -> Vec<Diagnostic>
What was reported, in the order it was reported.