-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: semicolon_inside_block don't fire if block is surrounded by parens
#15421
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
Conversation
|
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
|
Lintcheck changes for eb11010
This comment will be updated if you push new changes |
|
So apparently the lint got smarter as a side effect of this PR.. I don't really understand what exactly caused that, but the suggestions do seem to be correct, so I've added a quick test case based on one of the added lint firings. If/when we figure out what caused the change, I'd of course give the commits and the test case more sensible names, and maybe minimize the test case further |
cf93045 to
620e596
Compare
|
also no idea why the |
620e596 to
168f1c5
Compare
|
r? clippy |
no change in stderr as one can see
will make it easier to switch to `EarlyContext` later
will make it easier to switch to `EarlyContext` later
- replace the check for trailing expr / last stmt with a check on last `block.stmts.last()` this by itself fixes the issue
168f1c5 to
eb11010
Compare
|
☔ The latest upstream changes (possibly 0126bc9) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Yeah this can't really be an early-pass lint because of the attribute thing can it.. looks like we'll need to go with the first approach after all |
Decided not to lint in this case after all, as per #15391 (comment) Supersedes #15421, fixes #15380, fixes #15389 changelog: [`semicolon_inside_block`]: don't lint if block is in parens
changelog: [
semicolon_inside_block]: don't fire if block is surrounded by parenssupersedes #15391, fixes #15380, fixes #15389
I changed to approach to ignore blocks surrounded by parens, as suggested in #15391 (comment).
To do that, I took inspiration from https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/attempted.20fix.20for.20disallowed_macros/near/532461016 and realized that this lint would benefit from being early-pass rather than late-pass, since that surfaces
ExprKind::Parenwhich we now can explicitly ignore. Well, implicitly rather -- the lint now matches only on aStmtKind::Semithat contains aExprKind::Block, without aExprKind::Parenlayer inbetween.