Skip to content

Commit a6748a4

Browse files
add unsafe block in unsafe function to fix ci errors
1 parent ad35412 commit a6748a4

File tree

1 file changed

+26
-26
lines changed
  • futures-util/src/stream/futures_unordered_internal

1 file changed

+26
-26
lines changed

futures-util/src/stream/futures_unordered_internal/mod.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -337,33 +337,34 @@ impl<K, Fut, S: ReleasesTask<K>> FuturesUnorderedInternal<K, Fut, S> {
337337
pub(crate) unsafe fn unlink(&mut self, task: *const Task<K, Fut>) -> Arc<Task<K, Fut>> {
338338
// Compute the new list length now in case we're removing the head node
339339
// and won't be able to retrieve the correct length later.
340-
let head = *self.head_all.get_mut();
341-
debug_assert!(!head.is_null());
342-
let new_len = *(*head).len_all.get() - 1;
343-
344-
let task = Arc::from_raw(task);
345-
let next = task.next_all.load(Relaxed);
346-
let prev = *task.prev_all.get();
347-
task.next_all.store(self.pending_next_all(), Relaxed);
348-
*task.prev_all.get() = ptr::null_mut();
349-
350-
if !next.is_null() {
351-
*(*next).prev_all.get() = prev;
352-
}
340+
unsafe {
341+
let head = *self.head_all.get_mut();
342+
debug_assert!(!head.is_null());
343+
let new_len = *(*head).len_all.get() - 1;
353344

354-
if !prev.is_null() {
355-
(*prev).next_all.store(next, Relaxed);
356-
} else {
357-
*self.head_all.get_mut() = next;
358-
}
345+
let task = Arc::from_raw(task);
346+
let next = task.next_all.load(Relaxed);
347+
let prev = *task.prev_all.get();
348+
task.next_all.store(self.pending_next_all(), Relaxed);
349+
*task.prev_all.get() = ptr::null_mut();
359350

360-
// Store the new list length in the head node.
361-
let head = *self.head_all.get_mut();
362-
if !head.is_null() {
363-
*(*head).len_all.get() = new_len;
364-
}
351+
if !next.is_null() {
352+
*(*next).prev_all.get() = prev;
353+
}
365354

366-
task
355+
if !prev.is_null() {
356+
(*prev).next_all.store(next, Relaxed);
357+
} else {
358+
*self.head_all.get_mut() = next;
359+
}
360+
361+
// Store the new list length in the head node.
362+
let head = *self.head_all.get_mut();
363+
if !head.is_null() {
364+
*(*head).len_all.get() = new_len;
365+
}
366+
task
367+
}
367368
}
368369

369370
/// Returns the reserved value for `Task::next_all` to indicate a pending
@@ -420,9 +421,8 @@ impl<K, Fut: Future, S: ReleasesTask<K>> Stream for FuturesUnorderedInternal<K,
420421
// have yielded a `None`
421422
*self.is_terminated.get_mut() = true;
422423
return Poll::Ready(None);
423-
} else {
424-
return Poll::Pending;
425424
}
425+
return Poll::Pending;
426426
}
427427
Dequeue::Inconsistent => {
428428
// At this point, it may be worth yielding the thread &

0 commit comments

Comments
 (0)