2020-03-18 01:51:43 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2020-04-15 21:08:26 +00:00
|
|
|
--> $DIR/if_let_mutex.rs:10:5
|
2020-03-18 01:51:43 +00:00
|
|
|
|
|
2022-08-10 18:56:44 +00:00
|
|
|
LL | if let Err(locked) = m.lock() {
|
2022-08-15 18:13:31 +00:00
|
|
|
| ^ - this Mutex will remain locked for the entire `if let`-block...
|
2022-08-10 18:56:44 +00:00
|
|
|
| _____|
|
|
|
|
| |
|
2020-03-18 01:51:43 +00:00
|
|
|
LL | | do_stuff(locked);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let lock = m.lock().unwrap();
|
2022-08-10 18:56:44 +00:00
|
|
|
| | - ... and is tried to lock again here, which will always deadlock.
|
2020-03-18 01:51:43 +00:00
|
|
|
LL | | do_stuff(lock);
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= note: `-D clippy::if-let-mutex` implied by `-D warnings`
|
|
|
|
= help: move the lock call outside of the `if let ...` expression
|
|
|
|
|
2020-04-15 21:08:26 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2020-04-20 19:47:08 +00:00
|
|
|
--> $DIR/if_let_mutex.rs:22:5
|
2020-04-15 21:08:26 +00:00
|
|
|
|
|
2022-08-10 18:56:44 +00:00
|
|
|
LL | if let Some(locked) = m.lock().unwrap().deref() {
|
2022-08-15 18:13:31 +00:00
|
|
|
| ^ - this Mutex will remain locked for the entire `if let`-block...
|
2022-08-10 18:56:44 +00:00
|
|
|
| _____|
|
|
|
|
| |
|
2020-04-15 21:08:26 +00:00
|
|
|
LL | | do_stuff(locked);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let lock = m.lock().unwrap();
|
2022-08-10 18:56:44 +00:00
|
|
|
| | - ... and is tried to lock again here, which will always deadlock.
|
2020-04-15 21:08:26 +00:00
|
|
|
LL | | do_stuff(lock);
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: move the lock call outside of the `if let ...` expression
|
|
|
|
|
2022-08-10 17:40:42 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
|
|
|
--> $DIR/if_let_mutex.rs:43:5
|
|
|
|
|
|
2022-08-10 18:56:44 +00:00
|
|
|
LL | if let Ok(i) = mutex.lock() {
|
2022-08-15 18:13:31 +00:00
|
|
|
| ^ ----- this Mutex will remain locked for the entire `if let`-block...
|
2022-08-10 18:56:44 +00:00
|
|
|
| _____|
|
|
|
|
| |
|
2022-08-10 17:40:42 +00:00
|
|
|
LL | | do_stuff(i);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let _x = mutex.lock();
|
2022-08-10 18:56:44 +00:00
|
|
|
| | ----- ... and is tried to lock again here, which will always deadlock.
|
2022-08-10 17:40:42 +00:00
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: move the lock call outside of the `if let ...` expression
|
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
2020-03-18 01:51:43 +00:00
|
|
|
|