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

Stop linting else if let pattern in [option_if_let_else] lint #7216

Merged
merged 1 commit into from
May 17, 2021

Conversation

ThibsG
Copy link
Contributor

@ThibsG ThibsG commented May 13, 2021

For readability concerns, it is counterproductive to lint else if let pattern.
Unfortunately the suggested code is much less readable.

Fixes: #7006

changelog: stop linting else if let pattern in [option_if_let_else] lint

@rust-highfive
Copy link

r? @llogiq

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 13, 2021
if arms.len() == 2;
if !is_result_ok(cx, cond_expr); // Don't lint on Result::ok because a different lint does it already
if let PatKind::TupleStruct(struct_qpath, &[inner_pat], _) = &arms[0].pat.kind;
if is_lang_ctor(cx, struct_qpath, OptionSome);
if let PatKind::Binding(bind_annotation, _, id, _) = &inner_pat.kind;
if !contains_return_break_continue_macro(arms[0].body);
if !contains_return_break_continue_macro(arms[1].body);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's that empty line for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! that's en habit for readability, I should have discard it before pushing, sorry

@llogiq
Copy link
Contributor

llogiq commented May 17, 2021

Regardless of the empty line, this is a good improvement. And I don't think an empty line should matter that much. So @bors r+ from my side.

@bors
Copy link
Contributor

bors commented May 17, 2021

📌 Commit 368e621 has been approved by llogiq

@bors
Copy link
Contributor

bors commented May 17, 2021

⌛ Testing commit 368e621 with merge 44e0747...

@bors
Copy link
Contributor

bors commented May 17, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 44e0747 to master...

@bors bors merged commit 44e0747 into rust-lang:master May 17, 2021
@ThibsG ThibsG deleted the OptionIfLetElse7006 branch May 17, 2021 06:44
bors added a commit that referenced this pull request May 17, 2021
bors added a commit that referenced this pull request May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clippy::option-if-let-else suggests a worse code.
4 participants