blob: ccac73be79e4dd38abc4257507204a4e4b299b2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#![warn(clippy::let_underscore_lock)]
extern crate parking_lot;
fn main() {
use parking_lot::lock_api::RawMutex;
use parking_lot::{Mutex, RwLock};
let p_m: Mutex<()> = Mutex::const_new(RawMutex::INIT, ());
let _ = p_m.lock();
//~^ ERROR: non-binding `let` on a synchronization lock
let p_m1 = Mutex::new(0);
let _ = p_m1.lock();
//~^ ERROR: non-binding `let` on a synchronization lock
let p_rw = RwLock::new(0);
let _ = p_rw.read();
//~^ ERROR: non-binding `let` on a synchronization lock
let _ = p_rw.write();
//~^ ERROR: non-binding `let` on a synchronization lock
// These shouldn't throw an error.
let _ = p_m;
let _ = p_m1;
let _ = p_rw;
}
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;
}
|