Skip to content

Conversation

@y21
Copy link
Member

@y21 y21 commented Dec 16, 2023

Closes #11917

This could also lint e.g. if let (true, true, false) = (a, b, c) and suggest if a && b && c, but that's a change in semantics (going from eager to lazy, so I just left it out for now. Could be a future improvement.

changelog: [redundant_pattern_matching]: lint if let true, while let true, matches!(.., true)

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2023

r? @llogiq

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 16, 2023
@llogiq
Copy link
Contributor

llogiq commented Dec 16, 2023

Why only true and not also false? Otherwise this looks good and for the sake of avoiding rebase work, we can do that in a follow-up PR.

@bors r+

@bors
Copy link
Contributor

bors commented Dec 16, 2023

📌 Commit bc22407 has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Dec 16, 2023

⌛ Testing commit bc22407 with merge b918434...

@y21
Copy link
Member Author

y21 commented Dec 16, 2023

Why only true and not also false?

It should also lint false, forgot to mention that in the title/description. Or are you referring to something else?

LL | if let false = k > 5 {}
| ^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `!(k > 5)`

@bors
Copy link
Contributor

bors commented Dec 16, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Dec 16, 2023

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

@bors bors merged commit b918434 into rust-lang:master Dec 16, 2023
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.

if let true = k > 1 {} and if let true = true {}

4 participants