Struct rustc_mir_build::thir::pattern::deconstruct_pat::SplitWildcard
source · [−]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 seen in the matrix.
all_ctors: SmallVec<[Constructor<'tcx>; 1]>
All the constructors for this type
Implementations
sourceimpl<'tcx> SplitWildcard<'tcx>
impl<'tcx> SplitWildcard<'tcx>
pub(super) fn new<'p>(pcx: &PatCtxt<'_, 'p, 'tcx>) -> Self
sourcepub(super) fn split<'a>(
&mut self,
pcx: &PatCtxt<'_, '_, 'tcx>,
ctors: impl Iterator<Item = &'a Constructor<'tcx>> + Clone
)where
'tcx: 'a,
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.
sourcefn any_missing(&self, pcx: &PatCtxt<'_, '_, 'tcx>) -> bool
fn any_missing(&self, pcx: &PatCtxt<'_, '_, 'tcx>) -> bool
Whether there are any value constructors for this type that are not present in the matrix.
sourcepub(super) fn iter_missing<'a, 'p>(
&'a self,
pcx: &'a PatCtxt<'a, 'p, 'tcx>
) -> impl Iterator<Item = &'a Constructor<'tcx>> + Captures<'p>
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.
sourcefn into_ctors(
self,
pcx: &PatCtxt<'_, '_, 'tcx>
) -> SmallVec<[Constructor<'tcx>; 1]>
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
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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: 136 bytes