mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
Make liveness analysis respect privacy
This commit is contained in:
@@ -1197,7 +1197,8 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
|
||||
}
|
||||
|
||||
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 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
|
||||
}
|
||||
|
||||
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 @@ pub fn give_foo() -> Foo { panic!() }
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user