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>)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
Combine usefulnesses from two branches. This is an associative operation.
When trying several branches and each returns a Usefulness, we need to combine the
results together.
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
fn apply_constructor(
self,
pcx: PatCtxt<'_, 'p, 'tcx>,
matrix: &Matrix<'p, 'tcx>,
ctor: &Constructor<'tcx>,
ctor_wild_subpatterns: &Fields<'p, 'tcx>
) -> SelfAfter 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
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
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may be different between compiler versions and platforms. 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: 64 bytes