diff --git a/library/std/src/sync/mpmc/array.rs b/library/std/src/sync/mpmc/array.rs index 7038176000362..fb893695a9a58 100644 --- a/library/std/src/sync/mpmc/array.rs +++ b/library/std/src/sync/mpmc/array.rs @@ -464,14 +464,15 @@ impl Channel { /// ordering or stronger. pub(crate) unsafe fn disconnect_receivers(&self) -> bool { let tail = self.tail.fetch_or(self.mark_bit, Ordering::SeqCst); - self.discard_all_messages(tail); - - if tail & self.mark_bit == 0 { + let disconnected = if tail & self.mark_bit == 0 { self.senders.disconnect(); true } else { false - } + }; + + self.discard_all_messages(tail); + disconnected } /// Discards all messages.