Open
Description
Right now
trait T {}
impl T for () {}
fn should_ret_unit() -> impl T {
panic!()
}
compiles successfully, but
trait T {}
impl T for () {}
fn rec() -> impl T {
rec()
}
does not, even though
trait T {}
impl T for () {}
fn rec() -> ! {
rec()
}
does with the never_type
feature gate.
I think we should "just make it work" (it's actually less special casing in the compiler to make it work than to make it error).
Similarly, with type alias impl trait, when we have
trait T {}
impl T for i32 {}
type U = impl T;
fn foo() -> U {
panic!()
}
fn bar() -> U {
42
}
it should just compile, as foo
never produces any problematic value.