Skip to main content

Diagnostics

Struct Diagnostics 

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

A growing list of findings that keeps itself in reproducible order.

Callers push in whatever order problems are noticed; Diagnostics::finish imposes the order that makes two runs comparable.

The list is bounded. Past its ceiling, findings are counted rather than retained, and Diagnostics::finish appends one MOLFRAME-W1901 recording how many were suppressed. The worst severity still reflects every finding pushed, retained or not, so a decision taken on severity is unaffected by the ceiling.

Implementations§

Source§

impl Diagnostics

Source

pub const DEFAULT_CEILING: usize = 10_000

How many findings a list retains before it starts counting instead.

A systematically malformed column raises one finding per row, and a finding carries a message, a category, a field and a context vector — roughly ninety bytes and up to four allocations each. At a hundred million rows that is nine gigabytes of diagnostics describing a single cause, which exhausts memory reporting a problem rather than reporting it.

Ten thousand is far past the point where a reader learns anything new and far below the point where the list itself is the problem.

Source

pub const fn new() -> Self

Creates an empty list with the default ceiling.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a list with room for capacity findings.

Worth doing when a permissive parse over a known-messy file is expected to raise many, so the list does not grow by repeated reallocation. The ceiling is raised to capacity where that is higher than the default, because a caller who has reserved the room has said what they want.

Source

pub const fn with_ceiling(self, ceiling: usize) -> Self

Sets how many findings this list retains before counting instead.

Source

pub const fn ceiling(&self) -> usize

How many findings this list retains before counting instead.

Source

pub const fn suppressed(&self) -> u64

How many findings were counted rather than retained.

Source

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

Records a finding.

Past the ceiling the finding is counted and dropped. The severity is recorded either way, so nothing that depends on the worst severity changes with the ceiling.

Source

pub const fn worst(&self) -> Option<Severity>

The worst severity recorded so far, if anything has been.

Source

pub fn has_error(&self, strictness: Strictness) -> bool

Returns true when any recorded finding is an error at this strictness.

Source

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

The findings recorded so far, in the order they were pushed.

Source

pub fn is_empty(&self) -> bool

Returns true when nothing has been recorded.

Source

pub fn len(&self) -> usize

The number of findings recorded.

Source

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

Consumes the list, returning the findings in reproducible order.

The sort is stable, so two findings identical on every ordering key stay in the order they were raised.

Trait Implementations§

Source§

impl Clone for Diagnostics

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostics

Source§

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

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

impl Default for Diagnostics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Extend<Diagnostic> for Diagnostics

Source§

fn extend<T: IntoIterator<Item = Diagnostic>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. 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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.