]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock |
2 | --> $DIR/if_let_mutex.rs:10:5 | |
3 | | | |
f2b60f7d FG |
4 | LL | if let Err(locked) = m.lock() { |
5 | | ^ - this Mutex will remain locked for the entire `if let`-block... | |
6 | | _____| | |
7 | | | | |
f20569fa XL |
8 | LL | | do_stuff(locked); |
9 | LL | | } else { | |
10 | LL | | let lock = m.lock().unwrap(); | |
f2b60f7d | 11 | | | - ... and is tried to lock again here, which will always deadlock. |
f20569fa XL |
12 | LL | | do_stuff(lock); |
13 | LL | | }; | |
14 | | |_____^ | |
15 | | | |
16 | = note: `-D clippy::if-let-mutex` implied by `-D warnings` | |
17 | = help: move the lock call outside of the `if let ...` expression | |
18 | ||
19 | error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock | |
20 | --> $DIR/if_let_mutex.rs:22:5 | |
21 | | | |
f2b60f7d FG |
22 | LL | if let Some(locked) = m.lock().unwrap().deref() { |
23 | | ^ - this Mutex will remain locked for the entire `if let`-block... | |
24 | | _____| | |
25 | | | | |
f20569fa XL |
26 | LL | | do_stuff(locked); |
27 | LL | | } else { | |
28 | LL | | let lock = m.lock().unwrap(); | |
f2b60f7d | 29 | | | - ... and is tried to lock again here, which will always deadlock. |
f20569fa XL |
30 | LL | | do_stuff(lock); |
31 | LL | | }; | |
32 | | |_____^ | |
33 | | | |
34 | = help: move the lock call outside of the `if let ...` expression | |
35 | ||
f2b60f7d FG |
36 | error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock |
37 | --> $DIR/if_let_mutex.rs:43:5 | |
38 | | | |
39 | LL | if let Ok(i) = mutex.lock() { | |
40 | | ^ ----- this Mutex will remain locked for the entire `if let`-block... | |
41 | | _____| | |
42 | | | | |
43 | LL | | do_stuff(i); | |
44 | LL | | } else { | |
45 | LL | | let _x = mutex.lock(); | |
46 | | | ----- ... and is tried to lock again here, which will always deadlock. | |
47 | LL | | }; | |
48 | | |_____^ | |
49 | | | |
50 | = help: move the lock call outside of the `if let ...` expression | |
51 | ||
52 | error: aborting due to 3 previous errors | |
f20569fa | 53 |