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

39 lines
791 B
Rust
Raw Normal View History

//@ check-pass
2024-01-18 21:14:16 +01:00
//@ edition: 2018
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![deny(unreachable_patterns)]
fn main() {}
enum Void {}
// A never pattern alone diverges.
2024-01-22 16:14:17 +01:00
fn never_arg(!: Void) -> ! {}
2024-01-22 16:14:17 +01:00
fn never_arg_returns_anything<T>(!: Void) -> T {}
2024-01-22 16:14:17 +01:00
fn ref_never_arg(&!: &Void) -> ! {}
fn never_let() -> ! {
let ptr: *const Void = std::ptr::null();
unsafe {
let ! = *ptr;
}
}
2024-01-22 16:14:17 +01:00
fn never_match() -> ! {
let ptr: *const Void = std::ptr::null();
unsafe {
match *ptr { ! };
}
2024-01-22 16:14:17 +01:00
// Ensures this typechecks because of divergence and not the type of the match expression.
println!();
}
2024-01-18 21:14:16 +01:00
// Note: divergence is not detected for async fns when the `!` is in the argument (#120240).
async fn async_let(x: Void) -> ! {
let ! = x;
}