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

Teach SpanlessEq binding IDs #6754

Merged
merged 3 commits into from
Feb 21, 2021
Merged

Conversation

camsteffen
Copy link
Contributor

@camsteffen camsteffen commented Feb 17, 2021

changelog: Fix collapsible_match false positive

Fixes #6740

This PR changes the way SpanlessEq determines whether two local variables are the same. Instead of checking that the names match, it checks that the HirIds match. If local bindings are declared within the expressions that are being compared, SpanlessEq will remember bindings that correspond to each other in a FxHashMap<HirId, HirId>. This makes SpanlessEq more flexible while also fixing false positives.

Example: { let x = 1; x + 2 } is equal to { let y = 1; y + 2 }.

CC @xFrednet I think this will resolve some concerns in #6463

@rust-highfive
Copy link

r? @flip1995

(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 Feb 17, 2021
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Feb 21, 2021

📌 Commit 9ad6e26 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Feb 21, 2021

⌛ Testing commit 9ad6e26 with merge d2ddf9c...

@bors
Copy link
Collaborator

bors commented Feb 21, 2021

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

@bors bors merged commit d2ddf9c into rust-lang:master Feb 21, 2021
@camsteffen camsteffen deleted the spanlesseq-res branch July 8, 2021 22:01
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.

collapsible_match suggestion changes behaviour
4 participants