-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
Conversation
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
Lintcheck changes for 168f1c5
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 |
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
620e596
to
168f1c5
Compare
changelog: [
semicolon_inside_block
]: don't fire if block is surrounded by parenssupersedes #15391, fixes #15380
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::Paren
which we now can explicitly ignore. Well, implicitly rather -- the lint now matches only on aStmtKind::Semi
that contains aExprKind::Block
, without aExprKind::Paren
layer inbetween.