2019-10-15 08:28:42 -05:00
|
|
|
// check-pass
|
2019-12-11 08:51:28 -06:00
|
|
|
#![feature(never_type, exhaustive_patterns)]
|
2017-07-26 23:51:09 -05:00
|
|
|
#![warn(unreachable_code)]
|
|
|
|
#![warn(unreachable_patterns)]
|
2017-01-17 07:32:27 -06:00
|
|
|
|
2017-01-20 10:08:37 -06:00
|
|
|
enum Void {}
|
|
|
|
|
|
|
|
impl From<Void> for i32 {
|
|
|
|
fn from(v: Void) -> i32 {
|
|
|
|
match v {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-17 07:32:27 -06:00
|
|
|
fn bar(x: Result<!, i32>) -> Result<u32, i32> {
|
|
|
|
x?
|
|
|
|
}
|
|
|
|
|
2017-01-20 08:57:38 -06:00
|
|
|
fn foo(x: Result<!, i32>) -> Result<u32, i32> {
|
|
|
|
let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?;
|
2017-07-26 23:51:09 -05:00
|
|
|
//~^ WARN unreachable pattern
|
|
|
|
//~| WARN unreachable expression
|
2017-01-20 08:57:38 -06:00
|
|
|
Ok(y)
|
|
|
|
}
|
|
|
|
|
2017-01-20 10:08:37 -06:00
|
|
|
fn qux(x: Result<u32, Void>) -> Result<u32, i32> {
|
|
|
|
Ok(x?)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn vom(x: Result<u32, Void>) -> Result<u32, i32> {
|
|
|
|
let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?;
|
2017-07-26 23:51:09 -05:00
|
|
|
//~^ WARN unreachable pattern
|
2017-01-20 10:08:37 -06:00
|
|
|
Ok(y)
|
|
|
|
}
|
|
|
|
|
2018-10-31 07:08:01 -05:00
|
|
|
|
|
|
|
fn main() {
|
2017-01-17 07:32:27 -06:00
|
|
|
let _ = bar(Err(123));
|
2017-01-20 08:57:38 -06:00
|
|
|
let _ = foo(Err(123));
|
2017-01-20 10:08:37 -06:00
|
|
|
let _ = qux(Ok(123));
|
|
|
|
let _ = vom(Ok(123));
|
2017-01-17 07:32:27 -06:00
|
|
|
}
|