Skip to content

if let true = k > 1 {} and if let true = true {} #11917

@Linus-Schwarz

Description

@Linus-Schwarz

What it does

Warn you that this is bad style, recommend removing the let binding

Advantage

Clearly, it is not idiomatic to use refutable pattern matching on booleans

Drawbacks

None as far as I know

Example

let k = 5;
if let true = k > 1 { /* */ }

Could be written as:

let k = 5;
if k > 1 { /* */ }

AND

if let true = true { /* some code */ }

Could be written as:

/* some code */

AND

if let true = false { /* some code */ }

Should trigger an unreachable code warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions