rust/tests/ui/uninhabited/void-branch.rs
2025-11-21 16:07:54 +00:00

32 lines
501 B
Rust

#![deny(unreachable_code)]
#![allow(deprecated, invalid_value)]
enum Void {}
fn with_void() {
if false {
unsafe {
std::mem::uninitialized::<Void>();
println!();
//~^ ERROR unreachable expression
}
}
println!();
}
fn infallible() -> std::convert::Infallible {
loop {}
}
fn with_infallible() {
if false {
infallible();
println!()
//~^ ERROR unreachable expression
}
println!()
}
fn main() {}