Enum rustc_mir_build::thir::pattern::usefulness::Usefulness [−][src]
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>)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).
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]
fn new_useful(preference: WitnessPreference) -> Self[src]
fn new_not_useful(preference: WitnessPreference) -> 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]
pref: WitnessPreference,
usefulnesses: impl Iterator<Item = Self>
) -> Self
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]
self,
alt_id: usize,
alt_count: usize,
pat: &'p Pat<'tcx>
) -> Self
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]
self,
pcx: PatCtxt<'_, 'p, 'tcx>,
matrix: &Matrix<'p, 'tcx>,
ctor: &Constructor<'tcx>,
ctor_wild_subpatterns: &Fields<'p, 'tcx>
) -> Self
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]
fn clone(&self) -> Usefulness<'p, 'tcx>[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<'p, 'tcx> Debug for Usefulness<'p, 'tcx>[src]
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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,