]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/drop_ref.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / drop_ref.txt
1 ### What it does
2 Checks for calls to `std::mem::drop` with a reference
3 instead of an owned value.
4
5 ### Why is this bad?
6 Calling `drop` on a reference will only drop the
7 reference itself, which is a no-op. It will not call the `drop` method (from
8 the `Drop` trait implementation) on the underlying referenced value, which
9 is likely what was intended.
10
11 ### Example
12 ```
13 let mut lock_guard = mutex.lock();
14 std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
15 // still locked
16 operation_that_requires_mutex_to_be_unlocked();
17 ```