Add privately uninhabited dead code test

This commit is contained in:
varkor 2018-11-03 19:18:24 +00:00
parent cb4bd5a22c
commit 20415af142

View file

@ -0,0 +1,19 @@
// compile-pass
#![deny(unreachable_code)]
mod foo {
enum Bar {}
#[allow(dead_code)]
pub struct Foo {
value: Bar, // "privately" uninhabited
}
pub fn give_foo() -> Foo { panic!() }
}
fn main() {
foo::give_foo();
println!("Hello, world!"); // ok: we can't tell that this code is dead
}