Skip to content

Warn when match variables start with an uppercase letter #10304

Closed
@kmcallister

Description

@kmcallister

I had code like

match e.kind {
    EndOfFile => return Ok(()),
    _         => return Err(()),
}

and got error: unreachable pattern on the second pattern. I hadn't imported std::rt::io::EndOfFile so rustc interpreted EndOfFile as a variable rather than an enum constructor.

Most Rust code follows the stylistic rule of capitalizing enum constructors and not capitalizing variables. So I think rustc should warn when binding a capitalized variable in a match — at least when it makes another pattern unreachable, but probably always.

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions