Enum rustc_mir_build::thir::pattern::usefulness::Usefulness[−][src]

enum Usefulness<'p, 'tcx> {
    NoWitnesses(SubPatSet<'p, 'tcx>),
    WithWitnesses(Vec<Witness<'tcx>>),
}

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).

WithWitnesses(Vec<Witness<'tcx>>)

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]

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]

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]

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> 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, 

impl<'p, 'tcx> !UnwindSafe for Usefulness<'p, '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> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

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.