struct Matrix<'p, Cx: PatCx> {
rows: Vec<MatrixRow<'p, Cx>>,
place_info: SmallVec<[PlaceInfo<Cx>; 2]>,
wildcard_row_is_relevant: bool,
}
Expand description
A 2D matrix. Represents a list of pattern-tuples under investigation.
Invariant: each row must have the same length, and each column must have the same type.
Invariant: the first column must not contain or-patterns. This is handled by
Matrix::push
.
In fact each column corresponds to a place inside the scrutinee of the match. E.g. after
specializing (,)
and Some
on a pattern of type (Option<u32>, bool)
, the first column of
the matrix will correspond to scrutinee.0.Some.0
and the second column to scrutinee.1
.
Fields§
§rows: Vec<MatrixRow<'p, Cx>>
Vector of rows. The rows must form a rectangular 2D array. Moreover, all the patterns of each column must have the same type. Each column corresponds to a place within the scrutinee.
place_info: SmallVec<[PlaceInfo<Cx>; 2]>
Track info about each place. Each place corresponds to a column in rows
, and their types
must match.
wildcard_row_is_relevant: bool
Track whether the virtual wildcard row used to compute exhaustiveness is relevant. See top of the file for details on relevancy.
Implementations§
source§impl<'p, Cx: PatCx> Matrix<'p, Cx>
impl<'p, Cx: PatCx> Matrix<'p, Cx>
sourcefn push(&mut self, row: MatrixRow<'p, Cx>)
fn push(&mut self, row: MatrixRow<'p, Cx>)
Pushes a new row to the matrix. Internal method, prefer Matrix::new
.
sourcefn new(
arms: &[MatchArm<'p, Cx>],
scrut_ty: Cx::Ty,
scrut_validity: PlaceValidity,
) -> Self
fn new( arms: &[MatchArm<'p, Cx>], scrut_ty: Cx::Ty, scrut_validity: PlaceValidity, ) -> Self
Build a new matrix from an iterator of MatchArm
s.
fn head_place(&self) -> Option<&PlaceInfo<Cx>>
fn column_count(&self) -> usize
fn rows( &self, ) -> impl Iterator<Item = &MatrixRow<'p, Cx>> + Clone + DoubleEndedIterator + ExactSizeIterator
fn rows_mut( &mut self, ) -> impl Iterator<Item = &mut MatrixRow<'p, Cx>> + DoubleEndedIterator + ExactSizeIterator
sourcefn heads(
&self,
) -> impl Iterator<Item = PatOrWild<'p, Cx>> + Clone + Captures<'_>
fn heads( &self, ) -> impl Iterator<Item = PatOrWild<'p, Cx>> + Clone + Captures<'_>
Iterate over the first pattern of each row.
sourcefn specialize_constructor(
&self,
pcx: &PlaceCtxt<'_, Cx>,
ctor: &Constructor<Cx>,
ctor_is_relevant: bool,
) -> Result<Matrix<'p, Cx>, Cx::Error>
fn specialize_constructor( &self, pcx: &PlaceCtxt<'_, Cx>, ctor: &Constructor<Cx>, ctor_is_relevant: bool, ) -> Result<Matrix<'p, Cx>, Cx::Error>
This computes specialize(ctor, self)
. See top of the file for explanations.
sourcefn unspecialize(&mut self, specialized: Self)
fn unspecialize(&mut self, specialized: Self)
Recover row usefulness and intersection information from a processed specialized matrix.
specialized
must come from self.specialize_constructor
.
Trait Implementations§
Auto Trait Implementations§
impl<'p, Cx> DynSend for Matrix<'p, Cx>
impl<'p, Cx> DynSync for Matrix<'p, Cx>
impl<'p, Cx> Freeze for Matrix<'p, Cx>
impl<'p, Cx> RefUnwindSafe for Matrix<'p, Cx>where
<Cx as PatCx>::Ty: RefUnwindSafe,
<Cx as PatCx>::PatData: RefUnwindSafe,
<Cx as PatCx>::VariantIdx: RefUnwindSafe,
<Cx as PatCx>::StrLit: RefUnwindSafe,
impl<'p, Cx> Send for Matrix<'p, Cx>
impl<'p, Cx> Sync for Matrix<'p, Cx>
impl<'p, Cx> Unpin for Matrix<'p, Cx>
impl<'p, Cx> UnwindSafe for Matrix<'p, Cx>where
<Cx as PatCx>::Ty: RefUnwindSafe + UnwindSafe,
<Cx as PatCx>::PatData: RefUnwindSafe,
<Cx as PatCx>::VariantIdx: RefUnwindSafe,
<Cx as PatCx>::StrLit: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.