From 4d09b7a3cb2cf9dd1d0dc72f271e485d07e849c7 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 14 Feb 2022 01:03:27 +0900 Subject: [PATCH 1/3] Fix Sync impl of BiLockGuard --- futures-util/src/lock/bilock.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/futures-util/src/lock/bilock.rs b/futures-util/src/lock/bilock.rs index 2f51ae7c98..2174079c83 100644 --- a/futures-util/src/lock/bilock.rs +++ b/futures-util/src/lock/bilock.rs @@ -224,6 +224,9 @@ pub struct BiLockGuard<'a, T> { bilock: &'a BiLock, } +// We allow parallel access to T via Deref, so Sync bound is also needed here. +unsafe impl Sync for BiLockGuard<'_, T> {} + impl Deref for BiLockGuard<'_, T> { type Target = T; fn deref(&self) -> &T { From 35a57e7977bf98a9d93040cc0cedae48197de860 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 14 Feb 2022 01:07:34 +0900 Subject: [PATCH 2/3] Fix stable_features warning ``` error: the feature `cfg_target_has_atomic` has been stable since 1.60.0 and no longer requires an attribute to enable --> futures/tests/no-std/src/lib.rs:3:12 | 3 | #![feature(cfg_target_has_atomic)] | ^^^^^^^^^^^^^^^^^^^^^ ``` --- futures/tests/no-std/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/futures/tests/no-std/src/lib.rs b/futures/tests/no-std/src/lib.rs index 308218d6b7..89a8fa1ff1 100644 --- a/futures/tests/no-std/src/lib.rs +++ b/futures/tests/no-std/src/lib.rs @@ -1,6 +1,5 @@ #![cfg(nightly)] #![no_std] -#![feature(cfg_target_has_atomic)] #[cfg(feature = "futures-core-alloc")] #[cfg(target_has_atomic = "ptr")] From 237f3924ec39167f47e063d3ace6606d4e0ac679 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 14 Feb 2022 01:20:59 +0900 Subject: [PATCH 3/3] Fix clippy::single_match warning ``` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> futures-executor/src/thread_pool.rs:349:9 | 349 | / match arc_self.mutex.notify() { 350 | | Ok(task) => arc_self.exec.state.send(Message::Run(task)), 351 | | Err(()) => {} 352 | | } | |_________^ help: try this: `if let Ok(task) = arc_self.mutex.notify() { arc_self.exec.state.send(Message::Run(task)) }` | = note: `-D clippy::single-match` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match ``` --- futures-executor/src/thread_pool.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/futures-executor/src/thread_pool.rs b/futures-executor/src/thread_pool.rs index 5e1f586eb8..3eca9d1440 100644 --- a/futures-executor/src/thread_pool.rs +++ b/futures-executor/src/thread_pool.rs @@ -346,9 +346,8 @@ impl fmt::Debug for Task { impl ArcWake for WakeHandle { fn wake_by_ref(arc_self: &Arc) { - match arc_self.mutex.notify() { - Ok(task) => arc_self.exec.state.send(Message::Run(task)), - Err(()) => {} + if let Ok(task) = arc_self.mutex.notify() { + arc_self.exec.state.send(Message::Run(task)) } } }