Skip to content

Exhaustiveness should ignore non-constructable patterns #15940

Closed
@brendanzab

Description

@brendanzab

Currently this does not compile:

enum Void {}

fn main() {
    let x = None::<Void>;
    match x {
        None => println!("hi"),
    }
}
<anon>:5:5: 7:6 error: non-exhaustive patterns: `Some(_)` not covered [E0004]
<anon>:5     match x {
<anon>:6         None => println!("hi"),
<anon>:7     }

playpen

I contend that because Some::<Void> is impossible to construct (Void is an uninhabited enum), exhaustiveness should not require it to be matched against.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions