about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-25 01:36:04 +0200
committerGitHub <noreply@github.com>2020-04-25 01:36:04 +0200
commitd0db0a8caffa2c4e28d9e806dee1949a5a564a66 (patch)
treec24f275e3be0459d86c5fde405426291e0fdc93d /src/libstd
parent2ca6df76a53da39698f152e703d519e62f1fc396 (diff)
parent2325c209257a8ce6c11200ebfc152907566f7a04 (diff)
downloadrust-d0db0a8caffa2c4e28d9e806dee1949a5a564a66.tar.gz
rust-d0db0a8caffa2c4e28d9e806dee1949a5a564a66.zip
Rollup merge of #71534 - cuviper:unused-option-map, r=Mark-Simulacrum
Avoid unused Option::map results

These are changes that would be needed if we add `#[must_use]` to `Option::map`, per #71484.

r? @Mark-Simulacrum
Diffstat (limited to 'src/libstd')
-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();
+        }
     }
 }