Assert, rather than hang, on shell-in-use assertions

Previously, `gctx.shell().verbosity()` was used to check that `gctx.shell` is
not borrowed. Since shell is now behind a `Mutex` and not a `RefCell`,
this would hang waiting for the unlock instead panicking. Borrow state
checking is now done using `Mutex::try_lock` in
`GlobalContext::debug_assert_shell_not_borrowed`
This commit is contained in:
Matyas Susits 2025-09-12 12:58:16 +02:00 committed by Ed Page
parent 3fd0af4da5
commit 9929c8796d

View File

@ -418,7 +418,10 @@ impl GlobalContext {
/// so place this outside of the conditions to catch these bugs in more situations. /// so place this outside of the conditions to catch these bugs in more situations.
pub fn debug_assert_shell_not_borrowed(&self) { pub fn debug_assert_shell_not_borrowed(&self) {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
self.shell().verbosity(); match self.shell.try_lock() {
Ok(_) | Err(std::sync::TryLockError::Poisoned(_)) => (),
Err(std::sync::TryLockError::WouldBlock) => panic!("shell is borrowed!"),
}
} }
} }