-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed
Description
Summary
The mut_mutex_lock
is emitted when there is a unique reference to a shared reference of a mutex and the lock
method is called. This is obviously a false positive.
Lint Name
mut_mutex_lock
Reproducer
I tried this code:
use std::sync::Mutex;
fn test(mutex: &mut &Mutex<i32>) {
let _x = mutex.lock().unwrap();
}
I saw this happen:
warning: calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference
--> src/lib.rs:4:20
|
4 | let _x = mutex.lock().unwrap();
| ^^^^ help: change this to: `get_mut`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mut_mutex_lock
= note: `#[warn(clippy::mut_mutex_lock)]` on by default
I expected to see this happen:
No lints are triggered.
Version
rustc 1.82.0-nightly (28a58f2fa 2024-07-31)
binary: rustc
commit-hash: 28a58f2fa7f0c46b8fab8237c02471a915924fe5
commit-date: 2024-07-31
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
Additional Labels
@rustbot label +I-suggestion-causes-error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedS-fixedStatus: Issues that got fixed, waiting to be closed as completedStatus: Issues that got fixed, waiting to be closed as completed