@@ -12,6 +12,7 @@ use std::io;
12
12
use std:: io:: { Read , Seek , SeekFrom , Write } ;
13
13
use std:: path:: { Display , Path , PathBuf } ;
14
14
15
+ use crate :: core:: Verbosity ;
15
16
use crate :: util:: errors:: CargoResult ;
16
17
use crate :: util:: style;
17
18
use crate :: util:: GlobalContext ;
@@ -392,18 +393,20 @@ fn acquire(
392
393
lock_try : & dyn Fn ( ) -> io:: Result < ( ) > ,
393
394
lock_block : & dyn Fn ( ) -> io:: Result < ( ) > ,
394
395
) -> CargoResult < ( ) > {
395
- if cfg ! ( debug_assertions) {
396
- // Force borrow to catch invalid borrows outside of contention situations
397
- gctx. shell ( ) . verbosity ( ) ;
398
- }
396
+ let verbose = gctx. shell ( ) . verbosity ( ) == Verbosity :: Verbose ;
399
397
if try_acquire ( path, lock_try) ? {
400
398
return Ok ( ( ) ) ;
401
399
}
402
- let msg = format ! ( "waiting for file lock on {}" , msg) ;
400
+ let path = path. display ( ) ;
401
+ let msg = if verbose {
402
+ format ! ( "waiting for file lock on {msg} ({path})" )
403
+ } else {
404
+ format ! ( "waiting for file lock on {msg}" )
405
+ } ;
403
406
gctx. shell ( )
404
407
. status_with_color ( "Blocking" , & msg, & style:: NOTE ) ?;
405
408
406
- lock_block ( ) . with_context ( || format ! ( "failed to lock file: {}" , path . display ( ) ) ) ?;
409
+ lock_block ( ) . with_context ( || format ! ( "failed to lock file: {path}" ) ) ?;
407
410
Ok ( ( ) )
408
411
}
409
412
0 commit comments