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