Skip to content

single_match should suggest plain if when possible #173

Closed
@Manishearth

Description

@Manishearth

Currently, for things like:

match foo
  Enum::Variant => {...}
  _ => {...}
}

we suggest using if let Enum::Variant = foo {...}. However, in many cases, the enum implements PartialEq, so we can just suggest if Enum::Variant == foo.

This involves checking if the patterns in the match are simple PatIdents or PatEnums with empty pat-vecs (http://manishearth.github.io/rust-internals-docs/syntax/ast/enum.Pat_.html), and then checking if the type implements Eq (not sure how this can be done, probably needs some mucking about in middle::ty)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions