Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useless_let_if_seq should not trigger on multiple assignments #3768

Closed
sgrif opened this issue Feb 16, 2019 · 1 comment
Closed

useless_let_if_seq should not trigger on multiple assignments #3768

sgrif opened this issue Feb 16, 2019 · 1 comment

Comments

@sgrif
Copy link

sgrif commented Feb 16, 2019

The following code triggers this lint:

let thing1;
let thing2;

if things.is_empty() {
    thing1 = None;
    thing2 = None;
} else {
    thing1 = Some(stuff1(things));
    thing2 = Some(stuff2(things));
}

while this can technically be written as a single expression such as

let (thing1, thing2) = if things.is_empty() {
    (None, None)
} else {
    (
        Some(stuff1(things)),
        Some(stuff2(things)),
    )
}

most folks I've polled agree that it's way harder to read, since the binding is so far removed from the expression its receiving. This lint makes complete sense if there's only a single assignment, but I think it should ignore multiple assignments in the same if statement

@jfirebaugh
Copy link

This is a duplicate of #2749.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants