RS.CLIPPY.SIGNIFICANT_DROP_TIGHTENING
Searches for elements marked with `#[clippy::has_significant_drop]` that could be early dropped but are in fact dropped at the end of their scopes
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: significant_drop_tightening. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Searches for elements marked with #[clippy::has_significant_drop] that could be early
dropped but are in fact dropped at the end of their scopes. In other words, enforces the
"tightening" of their possible lifetimes.
Why is this bad?
Elements marked with #[clippy::has_significant_drop] are generally synchronizing
primitives that manage shared resources, as such, it is desired to release them as soon as
possible to avoid unnecessary resource contention.
Example
fn main() {
let lock = some_sync_resource.lock();
let owned_rslt = lock.do_stuff_with_resource();
// Only `owned_rslt` is needed but `lock` is still held.
do_heavy_computation_that_takes_time(owned_rslt);
}
Use instead:
fn main() {
let owned_rslt = some_sync_resource.lock().do_stuff_with_resource();
do_heavy_computation_that_takes_time(owned_rslt);
}