@@ -216,7 +216,7 @@ impl SlotPtr {
216
216
/// Replace the value of this slot with `new_value`, and return
217
217
/// the old value.
218
218
///
219
- /// SAFETY: the pointer in this `SlotPtr` must still be valid.
219
+ /// SAFETY: the pointer in this `SlotPtr` must be valid for writes .
220
220
unsafe fn replace (
221
221
& mut self ,
222
222
new_value : Option < u8 > ,
@@ -317,7 +317,7 @@ impl<T, const N: usize> Sender<'_, T, N> {
317
317
// is no way for anything else to access the free slot ptr. Gotta think
318
318
// about this a bit more...
319
319
//
320
- // SAFETY(replace): the data pointed to by `free_slot_ptr2` is still alive .
320
+ // SAFETY(replace): `free_slot_ptr2` is valid for writes .
321
321
critical_section:: with ( |cs| {
322
322
if let Some ( freed_slot) = unsafe { free_slot_ptr2. replace ( None , cs) } {
323
323
debug_assert ! ( !self . 0 . access( cs) . freeq. is_full( ) ) ;
@@ -362,9 +362,8 @@ impl<T, const N: usize> Sender<'_, T, N> {
362
362
}
363
363
}
364
364
365
- // SAFETY: the value pointed to by `free_slot_ptr` is still alive.
366
- let slot = unsafe { free_slot_ptr. replace ( None , cs) }
367
- . or_else ( || self . 0 . access ( cs) . freeq . pop_back ( ) ) ;
365
+ // SAFETY: `free_slot_ptr` is valid for writes, as `free_slot_ptr` is still alive.
366
+ let slot = unsafe { free_slot_ptr. replace ( None , cs) } ;
368
367
369
368
if let Some ( slot) = slot {
370
369
Poll :: Ready ( Ok ( slot) )
@@ -475,7 +474,7 @@ impl<T, const N: usize> Receiver<'_, T, N> {
475
474
476
475
// If someone is waiting in the WaiterQueue, wake the first one up & hand it the free slot.
477
476
if let Some ( ( wait_head, mut freeq_slot) ) = self . 0 . wait_queue . pop ( ) {
478
- // SAFETY: the value pointed to by `freeq_slot` is still alive : we are in a critical
477
+ // SAFETY: `freeq_slot` is valid for writes : we are in a critical
479
478
// section & the `SlotPtr` lives for at least the duration of the wait queue link.
480
479
unsafe { freeq_slot. replace ( Some ( rs) , cs) } ;
481
480
wait_head. wake ( ) ;
0 commit comments