From 20415af14207cd4aae261de8ae7af81d4afdc21a Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Nov 2018 19:18:24 +0000 Subject: [PATCH] Add privately uninhabited dead code test --- .../privately-uninhabited-dead-code.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/ui/uninhabited/privately-uninhabited-dead-code.rs diff --git a/src/test/ui/uninhabited/privately-uninhabited-dead-code.rs b/src/test/ui/uninhabited/privately-uninhabited-dead-code.rs new file mode 100644 index 000000000000..602857ab1be3 --- /dev/null +++ b/src/test/ui/uninhabited/privately-uninhabited-dead-code.rs @@ -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 +}