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
significant_drop_in_scrutinee
: Trigger lint only if lifetime allows early significant drop
#12740
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
☔ The latest upstream changes (presumably #12745) made this pull request unmergeable. Please resolve the merge conflicts. |
I think those are really valuable changes, but won't get to reviewing those for quite a long time, so re-assigning r? clippy |
Hi @lrh2000, thanks for the contribution! I've looked at it and nothing triggers my alerts, but we'd prefer if you could split this PR into multiple others. This would help both in the review & merging process and with bisecting future possible bugs. Thanksies for your contribution! ❤️ |
Hi @blyxyas, thank you for your comment and advice. I am willing to do that. I plan to use three PRs to cover those three changelogs. (Maybe we can have more, like one PR for each commit, but I think there's a tradeoff.)
So this PR will only cover the second changelog. I'll temporarily mark it as a draft until the first PR (#12764) is merged. Since all these changes are in one file, they must be merged one at a time, or else there will be a bunch of conflicts to resolve (and break unit tests that depend on multiple fixes or features). |
☔ The latest upstream changes (presumably #12764) made this pull request unmergeable. Please resolve the merge conflicts. |
OK, now this PR contains only one commit "Trigger lint only if lifetime allows early significant drop". This commit should be atomic enough to be reviewed separately. I've updated the PR description accordingly. |
☔ The latest upstream changes (presumably #12813) made this pull request unmergeable. Please resolve the merge conflicts. |
I want to argue that the following code snippet should not trigger
significant_drop_in_scrutinee
(#8987). The iterator holds a reference to the locked data, so it is expected that the mutex guard must be alive until the entire loop is finished.However, the lint should be triggered when we clone the vector. In this case, the iterator does not hold any reference to the locked data.
Unfortunately, it seems that regions on the types of local variables are mostly erased (
ReErased
) in the late lint pass. So it is hard to tell if the final expression has a lifetime relevant to the value with a significant drop.In this PR, I try to make a best-effort guess based on the function signatures. To avoid false positives, no lint is issued if the result is uncertain. I'm not sure if this is acceptable or not, so any comments are welcome.
Fixes #8987
changelog: [
significant_drop_in_scrutinee
]: Trigger lint only if lifetime allows early significant drop.r? @flip1995