Repository navigation
Fix issue 11223: add check for identical guards in lint match_same_arms - #12059
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
aa8429c to
3a8e3af
Compare
|
☔ The latest upstream changes (presumably #12306) made this pull request unmergeable. Please resolve the merge conflicts. |
3a8e3af to
087c7c8
Compare
|
Thank you! Sorry for taking a while to get around to this @bors r+ |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #11223
In the current
match_same_armsimplementation, if arms have guards, they are considered different. This commit adds equality checking for guards: arms are now considered equivalent only when they either both have no guards or their guards are identical.The portion responsible for checking guard equality is refactored to reuse the existing code for checking body equality. This is abstracted into a function called
check_eq_with_pat. To optimize performance,check_same_guardandcheck_same_bodyhere use closures for lazy evaluation, ensuring that the calculation is only performed when!(backwards_blocking_idxs...)is true.changelog: [
match_same_arms]: Add check for identical guards