-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Compare empty blocks for equality based on tokens #6843
Conversation
…the tokens used are the same as well
r? @Manishearth (rust-highfive has picked a reviewer for you, use r? to override) |
Hmmm. This seems like it would be a large perf impact from reparsing, no? cc @flip1995 Can we potentially have a |
It's only running the lexer, not the full parser. It will also only run once a given block is determined to be empty. The performance impact should be basically zero. |
Oh, only for empty blocks, missed that sorry |
Why tokenize at all and not just compare the snippets directly? (You probably will have to trim away the braces and all white spaces and line breaks before comparing though) This would also take care of comments, that are not identical inside the blocks. |
The tokenizing is to deal with the whitespace. e.g. Should probably not skip comments though. |
@bors r+ I think it's fine to not skip comments |
📌 Commit 39c5e86 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes: #1390
This only considers empty blocks for now, though we should also catch something like this:
As far as I can tell there aren't any negative effects on other lints. These blocks only happen to be the same for a given compilation, not all compilations.
changelog: Fix
match_on_same_arms
and others. Only consider empty blocks equal if the tokens contained are the same.