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

enum Usefulness<'p, 'tcx> {
    NoWitnesses(SubPatSet<'p, 'tcx>),
    WithWitnesses(Vec<Witness<'tcx>>),
}
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).

WithWitnesses(Vec<Witness<'tcx>>)
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]

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]

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]

Performs copy-assignment from source. Read more

impl<'p, 'tcx> Debug for Usefulness<'p, 'tcx>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. 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, 

impl<'p, 'tcx> !UnwindSafe for Usefulness<'p, 'tcx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 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<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]