From 885ab76c0174bcd071e59624117f2d39f90b031a Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 22 May 2023 21:25:22 -0400 Subject: [PATCH 1/3] clippy::mem_replace_with_default warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> src/lib.rs:641:13 | 641 | mem::replace(self, Self::default()).into_inner() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default = note: `#[warn(clippy::mem_replace_with_default)]` on by default warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> src/lib.rs:1166:13 | 1166 | mem::replace(self, Self::default()).into_inner() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c2061f8..00cdd89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -638,7 +638,7 @@ pub mod unsync { /// cell = OnceCell::new(); /// ``` pub fn take(&mut self) -> Option { - mem::replace(self, Self::default()).into_inner() + mem::take(self).into_inner() } /// Consumes the `OnceCell`, returning the wrapped value. @@ -1163,7 +1163,7 @@ pub mod sync { /// cell = OnceCell::new(); /// ``` pub fn take(&mut self) -> Option { - mem::replace(self, Self::default()).into_inner() + mem::take(self).into_inner() } /// Consumes the `OnceCell`, returning the wrapped value. Returns From 307ff0c350bba45e07992b00eaf2d93fb0c146a7 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 22 May 2023 21:26:53 -0400 Subject: [PATCH 2/3] clippy::needless_borrow warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/imp_std.rs:212:22 | 212 | wait(&queue, curr_queue); | ^^^^^^ help: change this to: `queue` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default --- src/imp_std.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imp_std.rs b/src/imp_std.rs index 5761f01..b65e091 100644 --- a/src/imp_std.rs +++ b/src/imp_std.rs @@ -209,7 +209,7 @@ fn initialize_or_wait(queue: &AtomicPtr, mut init: Option<&mut dyn FnMut return; } (INCOMPLETE, None) | (RUNNING, _) => { - wait(&queue, curr_queue); + wait(queue, curr_queue); curr_queue = queue.load(Ordering::Acquire); } _ => debug_assert!(false), From 39933cd333134a2d187adccf67f6febccacf5450 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 22 May 2023 22:53:59 -0400 Subject: [PATCH 3/3] clippy::redundant_pattern_matching warning: redundant pattern matching, consider using `is_err()` --> src/race.rs:354:20 | 354 | if let Err(_) = exchange { | -------^^^^^^----------- help: try this: `if exchange.is_err()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching = note: `#[warn(clippy::redundant_pattern_matching)]` on by default --- src/race.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/race.rs b/src/race.rs index ee3d51a..fe36fa1 100644 --- a/src/race.rs +++ b/src/race.rs @@ -351,7 +351,7 @@ mod once_box { Ordering::AcqRel, Ordering::Acquire, ); - if let Err(_) = exchange { + if exchange.is_err() { let value = unsafe { Box::from_raw(ptr) }; return Err(value); }