-
Notifications
You must be signed in to change notification settings - Fork 2k
Lint nested and independent if let clauses #5218
Copy link
Copy link
Open
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started
Type
Fields
Give feedbackNo fields configured for issues without a type.
This code
could be written like this
which would remove a layer of nesting.
The lint should only lint nested
if letclauses, that are independent of each other.For example this must be ignored (or handled like in #2521):
but it should not matter, if there is code in between the
if letclauses, as long as it does not influence the otherif letclause(s):I think that there should not be a limit on how many nested
if letclauses should be linted, because it would improve the readability either way.Another thing to consider would be else clauses. I think this lint should only trigger, if the nested else clauses have the same body:
would become
It might be too difficult (for clippy), but it would be possible to refactor nested
if let-clauses with differentelse-clauses too->
Should I move this issue in to several smaller ones?