Skip to content

Commit 64e7db5

Browse files
susitsmepage
authored andcommitted
fix shell borrow state debug asserts
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`
1 parent 523e2e3 commit 64e7db5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cargo/util/context/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ impl GlobalContext {
420420
/// so place this outside of the conditions to catch these bugs in more situations.
421421
pub fn debug_assert_shell_not_borrowed(&self) {
422422
if cfg!(debug_assertions) {
423-
self.shell().verbosity();
423+
match self.shell.try_lock() {
424+
Ok(_) | Err(std::sync::TryLockError::Poisoned(_)) => (),
425+
Err(std::sync::TryLockError::WouldBlock) => panic!("shell is borrowed!"),
426+
}
424427
}
425428
}
426429

0 commit comments

Comments
 (0)