enum Usefulness<'p, 'tcx> {
    NoWitnesses {
        useful: bool,
    },
    WithWitnesses(Vec<Witness<'p, '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 ArmType.

Variants§

§

NoWitnesses

Fields

§useful: bool

If we don’t care about witnesses, simply remember if the pattern was useful.

§

WithWitnesses(Vec<Witness<'p, 'tcx>>)

Carries a list of witnesses of non-exhaustiveness. If empty, indicates that the whole pattern is unreachable.

Implementations§

source§

impl<'p, 'tcx> Usefulness<'p, 'tcx>

source

fn new_useful(preference: ArmType) -> Self

source

fn new_not_useful(preference: ArmType) -> Self

source

fn is_useful(&self) -> bool

source

fn extend(&mut self, other: Self)

Combine usefulnesses from two branches. This is an associative operation.

source

fn apply_constructor( self, pcx: &PatCtxt<'_, 'p, 'tcx>, matrix: &Matrix<'p, 'tcx>, ctor: &Constructor<'tcx> ) -> Self

After calculating usefulness after a specialization, call this to reconstruct 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§

source§

impl<'p, 'tcx> Debug for Usefulness<'p, 'tcx>

source§

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

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>

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes

Size for each variant:

  • NoWitnesses: 9 bytes
  • WithWitnesses: 24 bytes