mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
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:
parent
3fd0af4da5
commit
9929c8796d
@ -418,7 +418,10 @@ impl GlobalContext {
|
||||
/// so place this outside of the conditions to catch these bugs in more situations.
|
||||
pub fn debug_assert_shell_not_borrowed(&self) {
|
||||
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!"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user