]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/drop_ref.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / drop_ref.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for calls to `std::mem::drop` with a reference
3instead of an owned value.
4
5### Why is this bad?
6Calling `drop` on a reference will only drop the
7reference itself, which is a no-op. It will not call the `drop` method (from
8the `Drop` trait implementation) on the underlying referenced value, which
9is likely what was intended.
10
11### Example
12```
13let mut lock_guard = mutex.lock();
14std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
15// still locked
16operation_that_requires_mutex_to_be_unlocked();
17```