-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Incorrect suggestion for significant-drop-tightening #11125
Comments
It is necessary to have a reproducible use-case for testing purposes and the above warning couldn't be reproduced (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=61f94231278339353e05ba09b88a4d5c). However, an unrelated issue involving |
Well if you change the code changes are it's not going to reproduce the same issue... But if you just copy and paste it, it will: |
Thank you @Thomasdezeeuw. It turns out that the root cause of this issue was already fixed by #11129. In order to enhance the current test suite and to avoid similar errors in the future, a PR with the provided snippet has been submitted (#11131). |
@c410-f3r it's not fixed in it recommends:
But that doesn't work as The suggestion for https://github.com/Thomasdezeeuw/heph/blob/64a3e330dc9f3bdc40a4cb61b004ec17501cf2d8/inbox/src/lib.rs#L572-L580 is similar and also incorrect.
Finally the suggestion for https://github.com/Thomasdezeeuw/heph/blob/64a3e330dc9f3bdc40a4cb61b004ec17501cf2d8/inbox/src/lib.rs#L600-L611 also doesn't make a lot of sense as it suggests to drop the lock before a single constant statement, which I don't think will impact the performance (much).
Basically it's suggesting the following. let guard = mutex.lock().unwrap();
if condition(&guard) {
use(guard);
// Clippy's suggestion: drop(guard);
}
return true; |
@Thomasdezeeuw Local tests with the |
@c410-f3r I can confirm that this resolved, it doesn't give any (incorrect) suggestion any more! Thanks for resolving this! |
Summary
I've hit a false positive, or at least a bad suggestion, with the
significant-drop-tightening
lint where a mutex is used in two locations, but Clippy's suggestion doesn't consider the second usage of the locked value.Initially reported in #9399 (comment).
/cc @c410-f3r
Lint Name
significant-drop-tightening
Reproducer
The related code:
https://github.com/Thomasdezeeuw/heph/blob/8725fe9ed871f135b7ab87b5969eb1213121a242/inbox/src/lib.rs#L523-L529
For which Clippy suggests:
It doesn't seem to realize that
sender_wakers
is used twice, once to iterate over (line 524) and then to mutate it (line 526).Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: