rust/tests/ui/uninhabited/privately-uninhabited-dead-code.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
376 B
Rust
Raw Normal View History

// build-pass (FIXME(62277): could be check-pass?)
2018-11-06 13:38:01 -06:00
#![deny(unused_variables)]
mod foo {
enum Bar {}
#[allow(dead_code)]
pub struct Foo {
value: Bar, // "privately" uninhabited
}
pub fn give_foo() -> Foo { panic!() }
}
fn main() {
2018-11-06 13:38:01 -06:00
let a = 42;
foo::give_foo();
2018-11-06 13:38:01 -06:00
println!("Hello, {}", a); // ok: we can't tell that this code is dead
}