about summary refs log tree commit diff
path: root/src/libstd/sync/mpsc
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2020-04-24 13:58:41 -0700
committerJosh Stone <jistone@redhat.com>2020-04-24 13:58:41 -0700
commit2325c209257a8ce6c11200ebfc152907566f7a04 (patch)
tree3e7bb1afc2faee329bb27557bbb13a72f804f544 /src/libstd/sync/mpsc
parent3360cc3a0ea33c84d0b0b1163107b1c1acbf2a69 (diff)
downloadrust-2325c209257a8ce6c11200ebfc152907566f7a04.tar.gz
rust-2325c209257a8ce6c11200ebfc152907566f7a04.zip
Avoid unused Option::map results
These are changes that would be needed if we add `#[must_use]` to
`Option::map`, per #71484.
Diffstat (limited to 'src/libstd/sync/mpsc')
-rw-r--r--src/libstd/sync/mpsc/shared.rs4
-rw-r--r--src/libstd/sync/mpsc/sync.rs12
2 files changed, 11 insertions, 5 deletions
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<T> Packet<T> {
     //
     // This can only be called at channel-creation time
     pub fn inherit_blocker(&self, token: Option<SignalToken>, 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<T> Packet<T> {
             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<T> Packet<T> {
         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<T> Packet<T> {
         while let Some(token) = queue.dequeue() {
             token.signal();
         }
-        waiter.map(|t| t.signal());
+        if let Some(token) = waiter {
+            token.signal();
+        }
     }
 }