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

Fix needless_match FP on if-lets #13646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blyxyas
Copy link
Member

@blyxyas blyxyas commented Nov 2, 2024

Closes #13574

Make sure that needless_match doesn't simplify:

if let Some(_) = a() {
// ..
} else let Some(_) = b() {
// ..
}

to:

a()

changelog: [needless_match]: Fix false-positive on if lets

@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2024

r? @Centri3

rustbot has assigned @Centri3.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 2, 2024
Copy link
Member

@Centri3 Centri3 left a comment

Choose a reason for hiding this comment

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

This'll need to check method calls too, at least. It doesn't really seem like it checks the init expr at all before this, does it? So for example, mixing functions & constants has the same issue.

@blyxyas
Copy link
Member Author

blyxyas commented Nov 13, 2024

I'm not sure if we should just get two snippets at that point, I'll try doing manual pattern matching, but it might be the simplest solution

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.

Overzealous clippy::needless_match with multiple chained if let blocks
3 participants