Skip to content

"Unreachable pattern" warning could be an error #47811

Closed
@Badel2

Description

@Badel2

Why is "unreachable pattern" a warning and not an error? I found some discussion in the PR: #19115 but that was in 2014.

I'm specially concerned about the following use case: Playground

pub enum Bit {
    L,
    H,
}

fn from(x: Bit) -> u8 {
    match x {
        L => 0,
        H => 1,
    }
}

That code throws 8 warnings at me, but I would prefer it to not compile. I also found a similar problem in stackoverflow. I think it's important to make this a clear error so beginners don't get confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions