Change to Ty::is_inhabited_from
This commit is contained in:
parent
a6d96f9fd7
commit
34cbe72780
9 changed files with 73 additions and 81 deletions
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue