rustc_lint::drop_forget_useless

Static DROPPING_REFERENCES

source
pub static DROPPING_REFERENCES: &Lint
Expand description

The dropping_references lint checks for calls to std::mem::drop with a reference instead of an owned value.

§Example

let mut lock_guard = mutex.lock();
std::mem::drop(&lock_guard); // Should have been drop(lock_guard), mutex
// still locked
operation_that_requires_mutex_to_be_unlocked();

{{produces}}

§Explanation

Calling drop on a reference will only drop the reference itself, which is a no-op. It will not call the drop method (from the Drop trait implementation) on the underlying referenced value, which is likely what was intended.