pub(super) struct SplitWildcard<'tcx> {
    matrix_ctors: Vec<Constructor<'tcx>>,
    all_ctors: SmallVec<[Constructor<'tcx>; 1]>,
}
Expand description

A wildcard constructor that we split relative to the constructors in the matrix, as explained at the top of the file.

A constructor that is not present in the matrix rows will only be covered by the rows that have wildcards. Thus we can group all of those constructors together; we call them “missing constructors”. Splitting a wildcard would therefore list all present constructors individually (or grouped if they are integers or slices), and then all missing constructors together as a group.

However we can go further: since any constructor will match the wildcard rows, and having more rows can only reduce the amount of usefulness witnesses, we can skip the present constructors and only try the missing ones. This will not preserve the whole list of witnesses, but will preserve whether the list is empty or not. In fact this is quite natural from the point of view of diagnostics too. This is done in to_ctors: in some cases we only return Missing.

Fields§

§matrix_ctors: Vec<Constructor<'tcx>>

Constructors (other than wildcards and opaques) seen in the matrix.

§all_ctors: SmallVec<[Constructor<'tcx>; 1]>

All the constructors for this type

Implementations§

source§

impl<'tcx> SplitWildcard<'tcx>

source

pub(super) fn new<'p>(pcx: &PatCtxt<'_, 'p, 'tcx>) -> Self

source

pub(super) fn split<'a>( &mut self, pcx: &PatCtxt<'_, '_, 'tcx>, ctors: impl Iterator<Item = &'a Constructor<'tcx>> + Clone )where 'tcx: 'a,

Pass a set of constructors relative to which to split this one. Don’t call twice, it won’t do what you want.

source

fn any_missing(&self, pcx: &PatCtxt<'_, '_, 'tcx>) -> bool

Whether there are any value constructors for this type that are not present in the matrix.

source

pub(super) fn iter_missing<'a, 'p>( &'a self, pcx: &'a PatCtxt<'a, 'p, 'tcx> ) -> impl Iterator<Item = &'a Constructor<'tcx>> + Captures<'p>

Iterate over the constructors for this type that are not present in the matrix.

source

fn into_ctors( self, pcx: &PatCtxt<'_, '_, 'tcx> ) -> SmallVec<[Constructor<'tcx>; 1]>

Return the set of constructors resulting from splitting the wildcard. As explained at the top of the file, if any constructors are missing we can ignore the present ones.

Trait Implementations§

source§

impl<'tcx> Debug for SplitWildcard<'tcx>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'tcx> !RefUnwindSafe for SplitWildcard<'tcx>

§

impl<'tcx> Send for SplitWildcard<'tcx>

§

impl<'tcx> Sync for SplitWildcard<'tcx>

§

impl<'tcx> Unpin for SplitWildcard<'tcx>

§

impl<'tcx> !UnwindSafe for SplitWildcard<'tcx>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 128 bytes