Struct rustc_mir_build::thir::pattern::deconstruct_pat::SplitWildcard[−][src]

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

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 seen in the matrix.

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

All the constructors for this type

Implementations

impl<'tcx> SplitWildcard<'tcx>[src]

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

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

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

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

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

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

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

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

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

impl<'tcx> Debug for SplitWildcard<'tcx>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.