2020-03-18 01:51:43 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2024-11-16 09:52:42 +00:00
|
|
|
--> tests/ui/if_let_mutex.rs:16:5
|
2020-03-18 01:51:43 +00:00
|
|
|
|
|
2022-08-31 13:24:45 +00:00
|
|
|
LL | if let Err(locked) = m.lock() {
|
|
|
|
| ^ - this Mutex will remain locked for the entire `if let`-block...
|
|
|
|
| _____|
|
|
|
|
| |
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2020-03-18 01:51:43 +00:00
|
|
|
LL | | do_stuff(locked);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let lock = m.lock().unwrap();
|
2022-08-31 13:24:45 +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 | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: move the lock call outside of the `if let ...` expression
|
2022-09-22 16:04:22 +00:00
|
|
|
= note: `-D clippy::if-let-mutex` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::if_let_mutex)]`
|
2020-03-18 01:51:43 +00:00
|
|
|
|
2020-04-15 21:08:26 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2024-11-16 09:52:42 +00:00
|
|
|
--> tests/ui/if_let_mutex.rs:29:5
|
2020-04-15 21:08:26 +00:00
|
|
|
|
|
2022-08-31 13:24:45 +00:00
|
|
|
LL | if let Some(locked) = m.lock().unwrap().deref() {
|
|
|
|
| ^ - this Mutex will remain locked for the entire `if let`-block...
|
|
|
|
| _____|
|
|
|
|
| |
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2020-04-15 21:08:26 +00:00
|
|
|
LL | | do_stuff(locked);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let lock = m.lock().unwrap();
|
2022-08-31 13:24:45 +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-31 13:24:45 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2024-11-16 09:52:42 +00:00
|
|
|
--> tests/ui/if_let_mutex.rs:51:5
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | if let Ok(i) = mutex.lock() {
|
|
|
|
| ^ ----- this Mutex will remain locked for the entire `if let`-block...
|
|
|
|
| _____|
|
|
|
|
| |
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2022-08-31 13:24:45 +00:00
|
|
|
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
|
|
|
|
|
2024-07-28 16:27:53 +00:00
|
|
|
error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock
|
2024-11-16 09:52:42 +00:00
|
|
|
--> tests/ui/if_let_mutex.rs:60:5
|
2024-07-28 16:27:53 +00:00
|
|
|
|
|
|
|
|
LL | if let Ok(_) = m1.lock() {
|
|
|
|
| ^ -- this Mutex will remain locked for the entire `if let`-block...
|
|
|
|
| _____|
|
|
|
|
| |
|
|
|
|
LL | | m2.lock();
|
|
|
|
LL | | } else {
|
|
|
|
LL | | m1.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 4 previous errors
|
2020-03-18 01:51:43 +00:00
|
|
|
|