rust/tests/ui/reachable/unwarned-match-on-never.rs

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

25 lines
452 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 bar() {
match (return) {
() => () //~ ERROR unreachable arm
}
}
fn main() {
return;
match () { //~ ERROR unreachable expression
() => (),
}
}