Skip to content

Type inference failure in unreachable code #40073

Closed
@dhardy

Description

@dhardy

The following code works on stable 1.15.1 but not on current nightly compilers (Play editor):

enum X<T> {
    A(T), B
}

fn f(x: u32) -> X<()> {
    match x {
       _ => return X::A(()),
    }
    X::B
}

fn main() {
    f(0);
}

I encountered this using Result but realised a templated enum is sufficient. I can't replicate when replacing the match with an if.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions