Skip to content

Deny multiple catch all arms #86677

Closed
Closed
@andrewbanchich

Description

@andrewbanchich

Currently the compiler only issues warnings for cases like this:

enum Foo {
    A,
    B
}

fn main() {
    let foo = Foo::B;
    
    match foo {
        A => println!("A"),
        B => println!("B"),
    };
}

which prints A since it's interpreting both A and B arms as catch alls.

I can't think of any possible scenario where one could use multiple catch all arms for anything, so it may be beneficial to deny compiling this altogether.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-patternsRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions