mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #13651 - weihanglo:borrow_mut, r=epage
test: Add asserts to catch BorrowMutError's ### What does this PR try to resolve? This intentionally borrows from `RefCell`s before conditional code to try to prevent regressions like #13646 without exhaustively covering every case that could hit these `BorrowMutError`s with complicated tests. ### How should we test and review this PR? I tested this by ensuring the registry code path panicked before rebasing on top of #13647. Once I rebased, the panic went away. ### Additional information Split off from #13649 to try to avoid appveyor
This commit is contained in:
commit
5b2b1c036c
@ -739,6 +739,11 @@ impl<'gctx> Registry for PackageRegistry<'gctx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn block_until_ready(&mut self) -> CargoResult<()> {
|
fn block_until_ready(&mut self) -> CargoResult<()> {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
// Force borrow to catch invalid borrows, regardless of which source is used and how it
|
||||||
|
// happens to behave this time
|
||||||
|
self.gctx.shell().verbosity();
|
||||||
|
}
|
||||||
for (source_id, source) in self.sources.sources_mut() {
|
for (source_id, source) in self.sources.sources_mut() {
|
||||||
source
|
source
|
||||||
.block_until_ready()
|
.block_until_ready()
|
||||||
|
@ -392,6 +392,10 @@ fn acquire(
|
|||||||
lock_try: &dyn Fn() -> io::Result<()>,
|
lock_try: &dyn Fn() -> io::Result<()>,
|
||||||
lock_block: &dyn Fn() -> io::Result<()>,
|
lock_block: &dyn Fn() -> io::Result<()>,
|
||||||
) -> CargoResult<()> {
|
) -> CargoResult<()> {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
// Force borrow to catch invalid borrows outside of contention situations
|
||||||
|
gctx.shell().verbosity();
|
||||||
|
}
|
||||||
if try_acquire(path, lock_try)? {
|
if try_acquire(path, lock_try)? {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user