1
Fork 0

Change to Ty::is_inhabited_from

This commit is contained in:
Cameron Steffen 2022-10-23 17:32:17 -05:00
parent a6d96f9fd7
commit 34cbe72780
9 changed files with 73 additions and 81 deletions

View file

@ -271,15 +271,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// MIR checks and ultimately whether code is accepted or not. We can only
// omit the return edge if a return type is visibly uninhabited to a module
// that makes the call.
target: if this.tcx.is_ty_uninhabited_from(
this.parent_module,
expr.ty,
this.param_env,
) {
None
} else {
Some(success)
},
target: expr
.ty
.is_inhabited_from(this.tcx, this.parent_module, this.param_env)
.then_some(success),
from_hir_call,
fn_span,
},

View file

@ -818,7 +818,7 @@ fn non_exhaustive_match<'p, 'tcx>(
}
}
if let ty::Ref(_, sub_ty, _) = scrut_ty.kind() {
if cx.tcx.is_ty_uninhabited_from(cx.module, *sub_ty, cx.param_env) {
if !sub_ty.is_inhabited_from(cx.tcx, cx.module, cx.param_env) {
err.note("references are always considered inhabited");
}
}

View file

@ -324,7 +324,7 @@ pub(crate) struct MatchCheckCtxt<'p, 'tcx> {
impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
pub(super) fn is_uninhabited(&self, ty: Ty<'tcx>) -> bool {
if self.tcx.features().exhaustive_patterns {
self.tcx.is_ty_uninhabited_from(self.module, ty, self.param_env)
!ty.is_inhabited_from(self.tcx, self.module, self.param_env)
} else {
false
}