From 197d9e850bc047feb3b2e3c3b450bb3dac103e43 Mon Sep 17 00:00:00 2001 From: sinu <65924192+sinui0@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:17:20 -0700 Subject: [PATCH] fix: clippy --fix --- crates/mpz-common/Cargo.toml | 2 +- crates/mpz-common/src/cpu.rs | 18 ++++++++---------- crates/mpz-common/src/id.rs | 1 + crates/mpz-fields/src/lib.rs | 2 +- crates/mpz-garble-core/src/evaluator.rs | 10 +--------- crates/mpz-garble-core/src/generator.rs | 14 +++----------- crates/mpz-garble-core/src/lib.rs | 4 ++-- crates/mpz-garble/src/protocol/deap/vm.rs | 2 +- crates/mpz-ot-core/src/test.rs | 18 ++++++++++-------- crates/mpz-ot/src/ideal/ot.rs | 3 ++- 10 files changed, 30 insertions(+), 44 deletions(-) diff --git a/crates/mpz-common/Cargo.toml b/crates/mpz-common/Cargo.toml index 7d057cc4..2dd1e3f5 100644 --- a/crates/mpz-common/Cargo.toml +++ b/crates/mpz-common/Cargo.toml @@ -25,7 +25,7 @@ serde = { workspace = true, features = ["derive"] } pollster.workspace = true rayon = { workspace = true, optional = true } cfg-if.workspace = true -tokio = { workspace = true, optional = true, default-features = false } +tokio = { workspace = true, optional = true } [dev-dependencies] tokio = { workspace = true, features = [ diff --git a/crates/mpz-common/src/cpu.rs b/crates/mpz-common/src/cpu.rs index 7cc4766c..e161a1dd 100644 --- a/crates/mpz-common/src/cpu.rs +++ b/crates/mpz-common/src/cpu.rs @@ -33,12 +33,12 @@ mod st { /// Executes a closure on the CPU backend. #[inline] - pub fn blocking(f: F) -> impl Future + Send + pub async fn blocking(f: F) -> R where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - async move { f() } + f() } } @@ -88,18 +88,16 @@ mod rayon_backend { } /// Executes a closure on the CPU backend. - pub fn blocking(f: F) -> impl Future + Send + pub async fn blocking(f: F) -> R where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - async move { - let (sender, receiver) = oneshot::channel(); - rayon::spawn(move || { - _ = sender.send(f()); - }); - receiver.await.expect("worker thread does not drop channel") - } + let (sender, receiver) = oneshot::channel(); + rayon::spawn(move || { + _ = sender.send(f()); + }); + receiver.await.expect("worker thread does not drop channel") } } diff --git a/crates/mpz-common/src/id.rs b/crates/mpz-common/src/id.rs index 42d7e55b..5344df68 100644 --- a/crates/mpz-common/src/id.rs +++ b/crates/mpz-common/src/id.rs @@ -83,6 +83,7 @@ pub struct Counter(u32); impl Counter { /// Increments the counter in place, returning the previous value. + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Self { let prev = self.0; self.0 += 1; diff --git a/crates/mpz-fields/src/lib.rs b/crates/mpz-fields/src/lib.rs index d71956d8..041a83c7 100644 --- a/crates/mpz-fields/src/lib.rs +++ b/crates/mpz-fields/src/lib.rs @@ -164,6 +164,6 @@ mod tests { assert!(GetBit::::get_bit(&a, 0)); assert_eq!(b, T::two_pow(T::BIT_SIZE as u32 - 1)); - assert!(GetBit::::get_bit(&b, (T::BIT_SIZE - 1) as usize)); + assert!(GetBit::::get_bit(&b, T::BIT_SIZE - 1)); } } diff --git a/crates/mpz-garble-core/src/evaluator.rs b/crates/mpz-garble-core/src/evaluator.rs index 9ea29035..f503ef0e 100644 --- a/crates/mpz-garble-core/src/evaluator.rs +++ b/crates/mpz-garble-core/src/evaluator.rs @@ -68,20 +68,12 @@ pub struct EvaluatorOutput { } /// Garbled circuit evaluator. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Evaluator { /// Buffer for the active labels. buffer: Vec