Skip to content

useless_let_if_seq should not warn when variable is set from multiple places. #3769

Open
@kevincox

Description

@kevincox

I have some code that looks like this.

let ok = true;

if check1() {
  // Log some info.
  ok = false;
}

if check2() {
  // Log some info.
  ok = false;
}

if check3() {
  // Log some info.
  ok = false;
}

However clippy gives me a useless_let_if_seq saying that I should merge the first if into the let. I don't think this is a helpful suggestion because 1) It makes the first check look special and 2) it distracts a bit from the true until marked false.

After thinking about this a bit I think that if the variable defined from the let is set from multiple locations in the code then this warning should probably be suppressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-styleLint: Belongs in the style lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions