Fix let_undescore_lock false-positive when binding without locking

Signed-off-by: Klim Tsoutsman <klimusha@gmail.com>
This commit is contained in:
Klim Tsoutsman 2022-06-13 13:08:50 +10:00 committed by Klim Tsoutsman
parent 6b762ee330
commit 65f700fa89
No known key found for this signature in database
GPG key ID: 65BBCF5B8416C884
4 changed files with 17 additions and 9 deletions

View file

@ -13,6 +13,10 @@ fn main() {
let _ = rw.try_read();
let _ = rw.try_write();
// These shouldn't throw an error.
let _ = m;
let _ = rw;
use parking_lot::{lock_api::RawMutex, Mutex, RwLock};
let p_m: Mutex<()> = Mutex::const_new(RawMutex::INIT, ());
@ -24,4 +28,9 @@ fn main() {
let p_rw = RwLock::new(0);
let _ = p_rw.read();
let _ = p_rw.write();
// These shouldn't throw an error.
let _ = p_m;
let _ = p_m1;
let _ = p_rw;
}

View file

@ -48,7 +48,7 @@ LL | let _ = rw.try_write();
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
error: non-binding let on a synchronization lock
--> $DIR/let_underscore_lock.rs:19:5
--> $DIR/let_underscore_lock.rs:23:5
|
LL | let _ = p_m.lock();
| ^^^^^^^^^^^^^^^^^^^
@ -56,7 +56,7 @@ LL | let _ = p_m.lock();
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
error: non-binding let on a synchronization lock
--> $DIR/let_underscore_lock.rs:22:5
--> $DIR/let_underscore_lock.rs:26:5
|
LL | let _ = p_m1.lock();
| ^^^^^^^^^^^^^^^^^^^^
@ -64,7 +64,7 @@ LL | let _ = p_m1.lock();
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
error: non-binding let on a synchronization lock
--> $DIR/let_underscore_lock.rs:25:5
--> $DIR/let_underscore_lock.rs:29:5
|
LL | let _ = p_rw.read();
| ^^^^^^^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | let _ = p_rw.read();
= help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop`
error: non-binding let on a synchronization lock
--> $DIR/let_underscore_lock.rs:26:5
--> $DIR/let_underscore_lock.rs:30:5
|
LL | let _ = p_rw.write();
| ^^^^^^^^^^^^^^^^^^^^^