Add block_scrutinee lint - #16855
Conversation
|
r? @llogiq rustbot has assigned @llogiq. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
No changes for 3ff2380 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
b6468ef to
eed7c9c
Compare
This comment has been minimized.
This comment has been minimized.
eed7c9c to
475876f
Compare
This comment has been minimized.
This comment has been minimized.
|
What is the behavior in the current edition? Would it make sense to check whether the block survives a lifetime check if the edition was updated? |
|
Hi @llogiq, thanks for taking a look!
because of this, we should warn unconditionally on older editions to catch these false assumptions without needing deeper type/lifetime checking. Let me know if you think we should still try to narrow the lint down! |
|
Please include a test that verifies that this does not trigger on the 2024 edition. |
The behavior of
I don't think so. Nobody is going to write |
|
@Darksonn Thanks for suggesting the improvements, I will update the PR to include them. |
475876f to
89131a5
Compare
|
Ok. I think the lint should suggest updating the edition in case the user actually wants the early drop – or moving the block into its own let stmt. |
89131a5 to
508183e
Compare
|
Hi @llogiq, thanks for the review!
I just added a help message for this in the new commit (508183e).
The suggestion to move the expression to a separate let statement was actually added in the previous commit after Alice's review! Let me know if you need me to change anything else! |
|
Hi @llogiq, just sending a gentle ping on this when you have a moment! All previous feedback has been addressed and the latest tests are passing. |
f68a460 to
6665061
Compare
This comment has been minimized.
This comment has been minimized.
a8db467 to
084c7cc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
084c7cc to
367a6a9
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
367a6a9 to
d0e06c5
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
d0e06c5 to
3ff2380
Compare
View all comments
This PR introduces a new late pass lint to catch scrutinees unnecessarily wrapped in blocks on older editions, preventing unintended behavior regarding temporary lifetimes.
Fixes #16827
changelog: new lint: [
block_scrutinee] to warn on scrutinees wrapped in blocks in older editions