Create clippy lint against unexpectedly late drop for temporaries in match scrutinee expressions#94206
Conversation
|
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. Please see the contribution instructions for more information. |
|
r? @oli-obk To other reviewers: I'm fully aware that the spans, diagnostic messages, documentation and tests are not in a state yet where the lint is ready for general usage. These will get resolved before asking to move the lint out of the nursery. |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #94329) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Hey @PrestonFrom, Clippy creates its changelog from the PR description. Could you include a changelog entry to ensure that this new lint is caught when the changelog is written. You can just add the following line: changelog: new lint [`significant_drop_in_scrutinee`] That would be a big help 🙃 |
|
Yes, I will do that! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
flip1995
left a comment
There was a problem hiding this comment.
Left some review comments, mostly about the code style.
It also seems like that something has gone wrong with the submodule updates. This PR shouldn't update any submodule.
This comment has been minimized.
This comment has been minimized.
Thank you for the review comments! I am not sure what happened with the submodules, but I think I have fixed it. I'm still adding tests, but would appreciate any feed back about the matches in |
This comment has been minimized.
This comment has been minimized.
flip1995
left a comment
There was a problem hiding this comment.
Thanks for addressing all the comments! I left an explanation on how I think the visitor implementation could look like. Getting this right without implementing and testing it is tricky though. So it might take some experimentation from you to get the visitor right. If you get stuck and think that the visitor approach doesn't work at all, please let me know and I will try to give you some more pointers / rethink if a visitor is the right approach.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
flip1995
left a comment
There was a problem hiding this comment.
I didn't review the tests and documentation yet.
|
@flip1995 Sorry for the delay -- I had a bit of trouble figuring out how to get the span/suggestion working with the match, but I think it's working. Please let me know if this approach doesn't actually work though. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors r+ Thanks! Great work! |
|
@bors r=flip1995 Not sure why the bot ignored you outright |
|
@bors ping |
|
This PR doesn't appear in the bors queue for some reason 🤔 |
|
Lemme try clicking the "synchronize" button? 🤔 |
|
Oh no! Sorry, I’m away from my computer until tonight. Please let me know if there’s anything I can do to help. |
|
@bors r=flip1995 |
|
📌 Commit d9e963f has been approved by |
|
Yeah, closing and reopening it is a lot simpler than what I did. Sorry haha! |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (4d1076c): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
|
Current PR description is wrong, there is no |
|
@klensy Apologies! I missed updating the PR description after the initial code reviews. I just updated it. Thank you for pointing it out! |
A new clippy lint for issue 93883 (#93883). Relies on adding a new attribute (
clippy::has_significant_drop) toMutexGuard,RwLockReadGuard, andRwLockWriteGuard, which is why this PR is for the rust-lang repo and not the clippy repo.changelog: new lint [
significant_drop_in_scrutinee]