Make liveness analysis respect privacy
This commit is contained in:
parent
20415af142
commit
210e234733
2 changed files with 7 additions and 4 deletions
|
|
@ -1197,7 +1197,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::Call(ref f, ref args) => {
|
||||
let succ = if self.tables.expr_ty(expr).conservative_is_uninhabited(self.ir.tcx) {
|
||||
let m = self.ir.tcx.hir.get_module_parent(expr.id);
|
||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
||||
self.s.exit_ln
|
||||
} else {
|
||||
succ
|
||||
|
|
@ -1207,7 +1208,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::MethodCall(.., ref args) => {
|
||||
let succ = if self.tables.expr_ty(expr).conservative_is_uninhabited(self.ir.tcx) {
|
||||
let m = self.ir.tcx.hir.get_module_parent(expr.id);
|
||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
||||
self.s.exit_ln
|
||||
} else {
|
||||
succ
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// compile-pass
|
||||
|
||||
#![deny(unreachable_code)]
|
||||
#![deny(unused_variables)]
|
||||
|
||||
mod foo {
|
||||
enum Bar {}
|
||||
|
|
@ -14,6 +14,7 @@ mod foo {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let a = 42;
|
||||
foo::give_foo();
|
||||
println!("Hello, world!"); // ok: we can't tell that this code is dead
|
||||
println!("Hello, {}", a); // ok: we can't tell that this code is dead
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue