rust/tests/ui/rfcs/rfc-0000-never_patterns/diverge-causes-unreachable-code.rs

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

37 lines
663 B
Rust
Raw Normal View History

#![feature(never_patterns)]
#![allow(incomplete_features)]
#![deny(unreachable_patterns)]
#![deny(unreachable_code)]
fn main() {}
enum Void {}
fn never_arg(!: Void) -> u32 {
println!();
//~^ ERROR unreachable statement
}
fn ref_never_arg(&!: &Void) -> u32 {
println!();
//~^ ERROR unreachable statement
}
fn never_let() -> u32 {
let ptr: *const Void = std::ptr::null();
unsafe {
let ! = *ptr;
}
println!();
//~^ ERROR unreachable statement
}
fn never_match() -> u32 {
let ptr: *const Void = std::ptr::null();
unsafe {
match *ptr { ! };
}
println!();
//~^ ERROR unreachable statement
}