2020-01-28 09:28:11 +00:00
|
|
|
#![warn(clippy::let_underscore_lock)]
|
|
|
|
|
2021-12-06 11:33:31 +00:00
|
|
|
extern crate parking_lot;
|
|
|
|
|
2020-01-28 09:28:11 +00:00
|
|
|
fn main() {
|
2023-07-17 08:19:29 +00:00
|
|
|
use parking_lot::lock_api::RawMutex;
|
|
|
|
use parking_lot::{Mutex, RwLock};
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
let p_m: Mutex<()> = Mutex::const_new(RawMutex::INIT, ());
|
|
|
|
let _ = p_m.lock();
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: non-binding `let` on a synchronization lock
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
let p_m1 = Mutex::new(0);
|
|
|
|
let _ = p_m1.lock();
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: non-binding `let` on a synchronization lock
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
let p_rw = RwLock::new(0);
|
|
|
|
let _ = p_rw.read();
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: non-binding `let` on a synchronization lock
|
2021-12-06 11:33:31 +00:00
|
|
|
let _ = p_rw.write();
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: non-binding `let` on a synchronization lock
|
2022-06-30 08:50:09 +00:00
|
|
|
|
|
|
|
// These shouldn't throw an error.
|
|
|
|
let _ = p_m;
|
|
|
|
let _ = p_m1;
|
|
|
|
let _ = p_rw;
|
2020-01-28 09:28:11 +00:00
|
|
|
}
|
2022-11-21 19:34:47 +00:00
|
|
|
|
2024-01-07 19:37:51 +00:00
|
|
|
#[allow(let_underscore_lock)]
|
2022-11-21 19:34:47 +00:00
|
|
|
fn uplifted() {
|
|
|
|
// shouldn't lint std locks as they were uplifted as rustc's `let_underscore_lock`
|
|
|
|
|
|
|
|
let m = std::sync::Mutex::new(());
|
|
|
|
let rw = std::sync::RwLock::new(());
|
|
|
|
|
|
|
|
let _ = m.lock();
|
|
|
|
let _ = rw.read();
|
|
|
|
let _ = rw.write();
|
|
|
|
let _ = m.try_lock();
|
|
|
|
let _ = rw.try_read();
|
|
|
|
let _ = rw.try_write();
|
|
|
|
|
|
|
|
let _ = m;
|
|
|
|
let _ = rw;
|
|
|
|
}
|