The following should probably result in the lint being emitted:
#![feature(never_type)]
pub fn foo(maybe_never: Option<!>) {
match maybe_never {
Some(_never) => {
println!("foo");
}
None => {}
}
}
as _never is matched on, and it has a diverging type.
Compare this with:
#![feature(never_type)]
pub fn foo(maybe_never: Option<!>) {
match maybe_never {
Some(never) => {
let _ = never;
println!("foo");
}
None => {}
}
}
Currently, the pattern type checking code does not care about diverges.
We should probably avoid fixing this in typeck and have this be fixed automatically (?) by moving diverges logic to MIR or some such.
cc @eddyb #68422 (comment).
The following should probably result in the lint being emitted:
as
_neveris matched on, and it has a diverging type.Compare this with:
Currently, the pattern type checking code does not care about
diverges.We should probably avoid fixing this in typeck and have this be fixed automatically (?) by moving
divergeslogic to MIR or some such.cc @eddyb #68422 (comment).