From 5b5084b180bbf1991c80d239f77393574181c411 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Mon, 31 Jan 2022 10:49:06 -0800 Subject: [PATCH] clippy --- plonky2/src/gadgets/arithmetic_u32.rs | 6 +++--- plonky2/src/gadgets/curve.rs | 4 ++-- plonky2/src/gadgets/nonnative.rs | 14 ++++++-------- plonky2/src/gates/range_check_u32.rs | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/plonky2/src/gadgets/arithmetic_u32.rs b/plonky2/src/gadgets/arithmetic_u32.rs index f57c1db5..8a0d5784 100644 --- a/plonky2/src/gadgets/arithmetic_u32.rs +++ b/plonky2/src/gadgets/arithmetic_u32.rs @@ -214,13 +214,13 @@ impl, const D: usize> SimpleGenerator } fn run_once(&self, witness: &PartitionWitness, out_buffer: &mut GeneratedValues) { - let x = witness.get_target(self.x.clone()); + let x = witness.get_target(self.x); let x_u64 = x.to_canonical_u64(); let low = x_u64 as u32; let high = (x_u64 >> 32) as u32; - out_buffer.set_u32_target(self.low.clone(), low); - out_buffer.set_u32_target(self.high.clone(), high); + out_buffer.set_u32_target(self.low, low); + out_buffer.set_u32_target(self.high, high); } } diff --git a/plonky2/src/gadgets/curve.rs b/plonky2/src/gadgets/curve.rs index 92f45242..2ff22319 100644 --- a/plonky2/src/gadgets/curve.rs +++ b/plonky2/src/gadgets/curve.rs @@ -110,9 +110,9 @@ impl, const D: usize> CircuitBuilder { let s_squared = self.mul_nonnative(&s, &s); let x_sum = self.add_nonnative(x2, x1); let x3 = self.sub_nonnative(&s_squared, &x_sum); - let x_diff = self.sub_nonnative(&x1, &x3); + let x_diff = self.sub_nonnative(x1, &x3); let prod = self.mul_nonnative(&s, &x_diff); - let y3 = self.sub_nonnative(&prod, &y1); + let y3 = self.sub_nonnative(&prod, y1); AffinePointTarget { x: x3, y: y3 } } diff --git a/plonky2/src/gadgets/nonnative.rs b/plonky2/src/gadgets/nonnative.rs index 637eaccc..245b0403 100644 --- a/plonky2/src/gadgets/nonnative.rs +++ b/plonky2/src/gadgets/nonnative.rs @@ -74,7 +74,7 @@ impl, const D: usize> CircuitBuilder { a: a.clone(), b: b.clone(), sum: sum.clone(), - overflow: overflow.clone(), + overflow, _phantom: PhantomData, }); @@ -120,7 +120,7 @@ impl, const D: usize> CircuitBuilder { self.add_simple_generator(NonNativeMultipleAddsGenerator:: { summands: summands.clone(), sum: sum.clone(), - overflow: overflow.clone(), + overflow, _phantom: PhantomData, }); @@ -161,7 +161,7 @@ impl, const D: usize> CircuitBuilder { a: a.clone(), b: b.clone(), diff: diff.clone(), - overflow: overflow.clone(), + overflow, _phantom: PhantomData, }); @@ -250,11 +250,10 @@ impl, const D: usize> CircuitBuilder { let expected_product = self.add_biguint(&mod_times_div, &one); self.connect_biguint(&product, &expected_product); - let inv = NonNativeTarget:: { + NonNativeTarget:: { value: inv_biguint, _phantom: PhantomData, - }; - inv + } } /// Returns `x % |FF|` as a `NonNativeTarget`. @@ -362,8 +361,7 @@ impl, const D: usize, FF: Field> SimpleGenerator fn dependencies(&self) -> Vec { self.summands .iter() - .map(|summand| summand.value.limbs.iter().map(|limb| limb.0)) - .flatten() + .flat_map(|summand| summand.value.limbs.iter().map(|limb| limb.0)) .collect() } diff --git a/plonky2/src/gates/range_check_u32.rs b/plonky2/src/gates/range_check_u32.rs index 0e73990d..79e91de8 100644 --- a/plonky2/src/gates/range_check_u32.rs +++ b/plonky2/src/gates/range_check_u32.rs @@ -141,7 +141,7 @@ impl, const D: usize> Gate for U32RangeCheckG _local_constants: &[F], ) -> Vec>> { let gen = U32RangeCheckGenerator { - gate: self.clone(), + gate: *self, gate_index, }; vec![Box::new(gen.adapter())]