Introduce InhabitedPredicate
This commit is contained in:
parent
0940040c04
commit
2928e9ef2c
8 changed files with 338 additions and 354 deletions
|
@ -264,14 +264,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
|
||||
i == variant_index || {
|
||||
self.tcx.features().exhaustive_patterns
|
||||
&& !v
|
||||
.uninhabited_from(
|
||||
self.tcx,
|
||||
substs,
|
||||
adt_def.adt_kind(),
|
||||
self.param_env,
|
||||
)
|
||||
.is_empty()
|
||||
&& v.inhabited_predicate(self.tcx, adt_def)
|
||||
.subst(self.tcx, substs)
|
||||
.apply_any_module(self.tcx, self.param_env)
|
||||
!= Some(true)
|
||||
}
|
||||
}) && (adt_def.did().is_local()
|
||||
|| !adt_def.is_variant_list_non_exhaustive());
|
||||
|
|
|
@ -988,10 +988,12 @@ impl<'tcx> SplitWildcard<'tcx> {
|
|||
.filter(|(_, v)| {
|
||||
// If `exhaustive_patterns` is enabled, we exclude variants known to be
|
||||
// uninhabited.
|
||||
let is_uninhabited = is_exhaustive_pat_feature
|
||||
&& v.uninhabited_from(cx.tcx, substs, def.adt_kind(), cx.param_env)
|
||||
.contains(cx.tcx, cx.module);
|
||||
!is_uninhabited
|
||||
!is_exhaustive_pat_feature
|
||||
|| v.inhabited_predicate(cx.tcx, *def).subst(cx.tcx, substs).apply(
|
||||
cx.tcx,
|
||||
cx.param_env,
|
||||
cx.module,
|
||||
)
|
||||
})
|
||||
.map(|(idx, _)| Variant(idx))
|
||||
.collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue