rust/src/test/ui/unreachable/unwarned-match-on-never.rs

19 lines
370 B
Rust
Raw Normal View History

#![deny(unreachable_code)]
#![allow(dead_code)]
#![feature(never_type)]
fn foo(x: !) -> bool {
// Explicit matches on the never type are unwarned.
match x {}
// But matches in unreachable code are warned.
match x {} //~ ERROR: unreachable expression
}
fn main() {
return;
match () { //~ ERROR: unreachable expression
() => (),
}
}