@@ -414,7 +414,7 @@ impl Semaphore {
414
414
} << Self :: PERMIT_SHIFT ;
415
415
416
416
let mut available = self . permits . load ( Acquire ) ;
417
- let mut acquired : usize ;
417
+ let mut acquired_shifted : usize ;
418
418
419
419
// We could acquire the lock right now, but that's going to be
420
420
// expensive. To optimize, we try once without holding the mutex
@@ -429,8 +429,8 @@ impl Semaphore {
429
429
return Poll :: Ready ( Err ( AcquireError :: closed ( ) ) ) ;
430
430
}
431
431
432
- acquired = cmp:: min ( available, still_needed) ;
433
- let remaining = available - acquired ;
432
+ acquired_shifted = cmp:: min ( available, still_needed) ;
433
+ let remaining = available - acquired_shifted ;
434
434
435
435
// Not all permits were immediately available, so this waiter will
436
436
// (probably) need to wait. We'll need to acquire a lock on the wait
@@ -439,7 +439,7 @@ impl Semaphore {
439
439
// Otherwise, if we subtract the permits and then acquire the lock,
440
440
// we might miss additional permits being added while waiting for
441
441
// the lock.
442
- if acquired < still_needed && queue_guard. is_none ( ) {
442
+ if acquired_shifted < still_needed && queue_guard. is_none ( ) {
443
443
queue_guard = Some ( self . waiters . lock ( ) ) ;
444
444
}
445
445
@@ -458,19 +458,19 @@ impl Semaphore {
458
458
self . resource_span . in_scope ( || {
459
459
tracing:: trace!(
460
460
target: "runtime::resource::state_update" ,
461
- permits = ( acquired >> Self :: PERMIT_SHIFT ) ,
461
+ permits = ( acquired_shifted >> Self :: PERMIT_SHIFT ) ,
462
462
permits. op = "sub" ,
463
463
) ;
464
464
} ) ;
465
465
466
466
// If the waiter gets all the permits at the first try, don't bother
467
467
// enqueuing it.
468
- if acquired == still_needed && !queued {
468
+ if acquired_shifted == still_needed && !queued {
469
469
#[ cfg( all( tokio_unstable, feature = "tracing" ) ) ]
470
470
self . resource_span . in_scope ( || {
471
471
tracing:: trace!(
472
472
target: "runtime::resource::async_op::state_update" ,
473
- permits_obtained = ( acquired >> Self :: PERMIT_SHIFT ) ,
473
+ permits_obtained = ( acquired_shifted >> Self :: PERMIT_SHIFT ) ,
474
474
permits. op = "add" ,
475
475
)
476
476
} ) ;
@@ -482,7 +482,7 @@ impl Semaphore {
482
482
return Poll :: Ready ( Err ( AcquireError :: closed ( ) ) ) ;
483
483
}
484
484
485
- acquired >>= Self :: PERMIT_SHIFT ;
485
+ let mut acquired = acquired_shifted >> Self :: PERMIT_SHIFT ;
486
486
487
487
if node. assign_permits ( & mut acquired) {
488
488
// If the waiter is happy with the acquired permits, return the
0 commit comments