-
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
[New Lint Request] If possible, suggest releasing sync locks early #9399
Comments
drop
call for every sync lock
To implement this, the However, I marked it as |
@rustbot claim |
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
* Mark `MutexGuard` with `#[clippy::has_significant_drop]` `#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399. * Include more structures
958: Mark some structures with `#[clippy::has_significant_drop]` r=taiki-e a=c410-f3r `#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and the soon-to-be-finished rust-lang/rust-clippy#9399. Co-authored-by: Caio <c410.f3r@gmail.com>
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
`#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished rust-lang/rust-clippy#9399.
I've hit a false positive, or at least a bad suggestion, with this lint using The related code: For which Clippy suggests:
It doesn't seem to realize that |
At least for Can you create another issue if the same behavior continues after the next Clippy update? |
Problem
Code that heavily depends on synchronous primitives like
Mutex
can suffer unnecessary resource contention if the lock is only released at the end of its scope throughDrop
but could in fact be released early.Request
A new lint called
sync_lock_drop
that asks for an explicit "inline" expression or an explicitdrop
call. The above snippets would then be rewritten as follows:Implementation
It is trivial to detect synchronous primitives of the standard library but third-party implementations are tricky to detect. What should be done here? Hard code a list of well-known crates or allow users to provide a list of custom types?
The text was updated successfully, but these errors were encountered: