Skip to content

Lint trait impls whose body accesses self.field instead of let Self { field } = self #3724

Open
@oli-obk

Description

@oli-obk

If the type is ever extended to contain more fields, the trait impl could be left behind and accidentally break the runtime behaviour. Using the let Self { field } syntax allows one to use a pattern that covers all fields (and ignores unneeded fields with field: _ explicitly).

In tandem the lint should complain about let Self { field, .. } and suggest to fill in other_field: _ patterns for the missing fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.L-complexityLint: Belongs in the complexity lint groupL-correctnessLint: Belongs in the correctness lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions