Skip to content

Commit 20415af

Browse files
committed
Add privately uninhabited dead code test
1 parent cb4bd5a commit 20415af

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// compile-pass
2+
3+
#![deny(unreachable_code)]
4+
5+
mod foo {
6+
enum Bar {}
7+
8+
#[allow(dead_code)]
9+
pub struct Foo {
10+
value: Bar, // "privately" uninhabited
11+
}
12+
13+
pub fn give_foo() -> Foo { panic!() }
14+
}
15+
16+
fn main() {
17+
foo::give_foo();
18+
println!("Hello, world!"); // ok: we can't tell that this code is dead
19+
}

0 commit comments

Comments
 (0)