I tried this code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=165744f32b174e1068e0813fe906735f
#![feature(never_type)]
struct A{n: usize}
fn a() -> Result<A, !> { Ok(A{n: 5}) }
fn main(){
let Ok(A{ n }) = a();
}
I expected the code to compile, because Err is obviously an irrefutable pattern here.
I'm not even sure this is a bug (maybe rust's typesystem cannot understand that n inconstructible pattern on a n + 1 variants enum make the last pattern irrefutable ?)
The example code compiles with #![feature(exhaustive_patterns)]
Oh i wasn't aware of this feature, tyvm, i'm closing this 馃槃
Most helpful comment
The example code compiles with
#![feature(exhaustive_patterns)]