Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never type fallback #10

Open
oli-obk opened this issue Nov 30, 2021 · 0 comments
Open

Never type fallback #10

oli-obk opened this issue Nov 30, 2021 · 0 comments
Labels
question Further information is requested

Comments

@oli-obk
Copy link

oli-obk commented Nov 30, 2021

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.

@oli-obk oli-obk added the question Further information is requested label Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant