Change to Ty::is_inhabited_from
This commit is contained in:
parent
a6d96f9fd7
commit
34cbe72780
9 changed files with 73 additions and 81 deletions
|
@ -1284,20 +1284,19 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
fn check_is_ty_uninhabited(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode {
|
||||
let ty = self.typeck_results.expr_ty(expr);
|
||||
let m = self.ir.tcx.parent_module(expr.hir_id).to_def_id();
|
||||
if self.ir.tcx.is_ty_uninhabited_from(m, ty, self.param_env) {
|
||||
match self.ir.lnks[succ] {
|
||||
LiveNodeKind::ExprNode(succ_span, succ_id) => {
|
||||
self.warn_about_unreachable(expr.span, ty, succ_span, succ_id, "expression");
|
||||
}
|
||||
LiveNodeKind::VarDefNode(succ_span, succ_id) => {
|
||||
self.warn_about_unreachable(expr.span, ty, succ_span, succ_id, "definition");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
self.exit_ln
|
||||
} else {
|
||||
succ
|
||||
if ty.is_inhabited_from(self.ir.tcx, m, self.param_env) {
|
||||
return succ;
|
||||
}
|
||||
match self.ir.lnks[succ] {
|
||||
LiveNodeKind::ExprNode(succ_span, succ_id) => {
|
||||
self.warn_about_unreachable(expr.span, ty, succ_span, succ_id, "expression");
|
||||
}
|
||||
LiveNodeKind::VarDefNode(succ_span, succ_id) => {
|
||||
self.warn_about_unreachable(expr.span, ty, succ_span, succ_id, "definition");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
self.exit_ln
|
||||
}
|
||||
|
||||
fn warn_about_unreachable(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue