Add privately uninhabited dead code test
This commit is contained in:
parent
cb4bd5a22c
commit
20415af142
1 changed files with 19 additions and 0 deletions
19
src/test/ui/uninhabited/privately-uninhabited-dead-code.rs
Normal file
19
src/test/ui/uninhabited/privately-uninhabited-dead-code.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue