From 2325c209257a8ce6c11200ebfc152907566f7a04 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 24 Apr 2020 13:58:41 -0700 Subject: Avoid unused Option::map results These are changes that would be needed if we add `#[must_use]` to `Option::map`, per #71484. --- src/libstd/sync/mpsc/shared.rs | 4 ++-- src/libstd/sync/mpsc/sync.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index c4e929624d7..fd9d61e99c2 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -91,7 +91,7 @@ impl Packet { // // This can only be called at channel-creation time pub fn inherit_blocker(&self, token: Option, guard: MutexGuard<'_, ()>) { - token.map(|token| { + if let Some(token) = token { assert_eq!(self.cnt.load(Ordering::SeqCst), 0); assert_eq!(self.to_wake.load(Ordering::SeqCst), 0); self.to_wake.store(unsafe { token.cast_to_usize() }, Ordering::SeqCst); @@ -118,7 +118,7 @@ impl Packet { unsafe { *self.steals.get() = -1; } - }); + } // When the shared packet is constructed, we grabbed this lock. The // purpose of this lock is to ensure that abort_selection() doesn't diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 3e2050799cc..79123903e92 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -343,8 +343,12 @@ impl Packet { mem::drop(guard); // only outside of the lock do we wake up the pending threads - pending_sender1.map(|t| t.signal()); - pending_sender2.map(|t| t.signal()); + if let Some(token) = pending_sender1 { + token.signal(); + } + if let Some(token) = pending_sender2 { + token.signal(); + } } // Prepares this shared packet for a channel clone, essentially just bumping @@ -410,7 +414,9 @@ impl Packet { while let Some(token) = queue.dequeue() { token.signal(); } - waiter.map(|t| t.signal()); + if let Some(token) = waiter { + token.signal(); + } } } -- cgit 1.4.1-3-g733a5