Enum rustc_mir_build::thir::pattern::usefulness::Usefulness [−][src]
Expand description
This carries the results of computing usefulness, as described at the top of the file. When
checking usefulness of a match branch, we use the NoWitnesses variant, which also keeps track
of potential unreachable sub-patterns (in the presence of or-patterns). When checking
exhaustiveness of a whole match, we use the WithWitnesses variant, which carries a list of
witnesses of non-exhaustiveness when there are any.
Which variant to use is dictated by WitnessPreference.
Variants
NoWitnesses(SubPatSet<'p, 'tcx>)Expand description
Carries a set of subpatterns that have been found to be reachable. If empty, this indicates
the whole pattern is unreachable. If not, this indicates that the pattern is reachable but
that some sub-patterns may be unreachable (due to or-patterns). In the absence of
or-patterns this will always be either Empty (the whole pattern is unreachable) or Full
(the whole pattern is reachable).
Expand description
Carries a list of witnesses of non-exhaustiveness. If empty, indicates that the whole pattern is unreachable.
Implementations
impl<'p, 'tcx> Usefulness<'p, 'tcx>[src]
impl<'p, 'tcx> Usefulness<'p, 'tcx>[src]fn new_useful(preference: WitnessPreference) -> Self[src]
fn new_not_useful(preference: WitnessPreference) -> Self[src]
fn extend(&mut self, other: Self)[src]
fn extend(&mut self, other: Self)[src]Combine usefulnesses from two branches. This is an associative operation.
fn merge(
pref: WitnessPreference,
usefulnesses: impl Iterator<Item = Self>
) -> Self[src]
fn merge(
pref: WitnessPreference,
usefulnesses: impl Iterator<Item = Self>
) -> Self[src]When trying several branches and each returns a Usefulness, we need to combine the
results together.
fn unsplit_or_pat(
self,
alt_id: usize,
alt_count: usize,
pat: &'p Pat<'tcx>
) -> Self[src]
fn unsplit_or_pat(
self,
alt_id: usize,
alt_count: usize,
pat: &'p Pat<'tcx>
) -> Self[src]After calculating the usefulness for a branch of an or-pattern, call this to make this usefulness mergeable with those from the other branches.
fn apply_constructor(
self,
pcx: PatCtxt<'_, 'p, 'tcx>,
matrix: &Matrix<'p, 'tcx>,
ctor: &Constructor<'tcx>,
ctor_wild_subpatterns: &Fields<'p, 'tcx>
) -> Self[src]
fn apply_constructor(
self,
pcx: PatCtxt<'_, 'p, 'tcx>,
matrix: &Matrix<'p, 'tcx>,
ctor: &Constructor<'tcx>,
ctor_wild_subpatterns: &Fields<'p, 'tcx>
) -> Self[src]After calculating usefulness after a specialization, call this to recontruct a usefulness that makes sense for the matrix pre-specialization. This new usefulness can then be merged with the results of specializing with the other constructors.
Trait Implementations
impl<'p, 'tcx> Clone for Usefulness<'p, 'tcx>[src]
impl<'p, 'tcx> Clone for Usefulness<'p, 'tcx>[src]fn clone(&self) -> Usefulness<'p, 'tcx>[src]
fn clone(&self) -> Usefulness<'p, 'tcx>[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]Performs copy-assignment from source. Read more
Auto Trait Implementations
impl<'p, 'tcx> !RefUnwindSafe for Usefulness<'p, 'tcx>
impl<'p, 'tcx> !Send for Usefulness<'p, 'tcx>
impl<'p, 'tcx> !Sync for Usefulness<'p, 'tcx>
impl<'p, 'tcx> Unpin for Usefulness<'p, 'tcx> where
'tcx: 'p,
'tcx: 'p,
impl<'p, 'tcx> !UnwindSafe for Usefulness<'p, 'tcx>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,