edits to address clippy with the latest Rust (#90)

This commit is contained in:
Srinath Setty
2022-07-13 14:46:13 -07:00
committed by GitHub
parent a04566bb81
commit e373f4633d
5 changed files with 26 additions and 27 deletions

View File

@@ -158,7 +158,7 @@ mod tests {
n_limbs,
)?;
let _ = a1.equal_when_carried(cs.namespace(|| "check equal"), &a2)?;
a1.equal_when_carried(cs.namespace(|| "check equal"), &a2)?;
Ok(())
}
@@ -182,7 +182,7 @@ mod tests {
limb_width,
n_limbs,
)?;
let _ = m.inputize(cs.namespace(|| "modulus m"))?;
m.inputize(cs.namespace(|| "modulus m"))?;
let a = BigNat::from_num(
cs.namespace(|| "allocate a_limbs"),
@@ -228,14 +228,14 @@ mod tests {
limb_width,
n_limbs,
)?;
let _ = a.inputize(cs.namespace(|| "input a"))?;
a.inputize(cs.namespace(|| "input a"))?;
let b = BigNat::alloc_from_nat(
cs.namespace(|| "b"),
|| Ok(b_val.clone()),
limb_width,
n_limbs,
)?;
let _ = b.inputize(cs.namespace(|| "input b"))?;
b.inputize(cs.namespace(|| "input b"))?;
let c = BigNat::alloc_from_nat(
cs.namespace(|| "c"),
|| Ok(c_val.clone()),
@@ -262,14 +262,14 @@ mod tests {
limb_width,
n_limbs,
)?;
let _ = a.inputize(cs.namespace(|| "input a"))?;
a.inputize(cs.namespace(|| "input a"))?;
let b = BigNat::alloc_from_nat(
cs.namespace(|| "b"),
|| Ok(b_val.clone()),
limb_width,
n_limbs,
)?;
let _ = b.inputize(cs.namespace(|| "input b"))?;
b.inputize(cs.namespace(|| "input b"))?;
let c = BigNat::alloc_from_nat(
cs.namespace(|| "c"),
|| Ok(c_val.clone()),

View File

@@ -6,9 +6,9 @@ use std::{
};
use crate::traits::Group;
use ff::{Field, PrimeField};
use bellperson::{ConstraintSystem, Index, LinearCombination, SynthesisError, Variable};
use core::fmt::Write;
use ff::{Field, PrimeField};
#[derive(Clone, Copy)]
struct OrderedVariable(Variable);
@@ -141,7 +141,7 @@ where
let mut s = String::new();
for input in &self.inputs {
s.push_str(&format!("INPUT {}\n", &input))
writeln!(s, "INPUT {}", &input).unwrap()
}
let negone = -<G::Scalar>::one();
@@ -164,20 +164,20 @@ where
if coeff != <G::Scalar>::one() && coeff != negone {
for (i, x) in powers_of_two.iter().enumerate() {
if x == &coeff {
s.push_str(&format!("2^{} . ", i));
write!(s, "2^{} . ", i).unwrap();
break;
}
}
s.push_str(&format!("{:?} . ", coeff))
write!(s, "{:?} . ", coeff).unwrap()
}
match var.0.get_unchecked() {
Index::Input(i) => {
s.push_str(&format!("`I{}`", &self.inputs[i]));
write!(s, "`I{}`", &self.inputs[i]).unwrap();
}
Index::Aux(i) => {
s.push_str(&format!("`A{}`", &self.aux[i]));
write!(s, "`A{}`", &self.aux[i]).unwrap();
}
}
}
@@ -191,9 +191,9 @@ where
for &(ref a, ref b, ref c, ref name) in &self.constraints {
s.push('\n');
s.push_str(&format!("{}: ", name));
write!(s, "{}: ", name).unwrap();
pp(&mut s, a);
s.push_str(" * ");
write!(s, " * ").unwrap();
pp(&mut s, b);
s.push_str(" = ");
pp(&mut s, c);

View File

@@ -225,7 +225,7 @@ where
ro.absorb(i);
ro.absorb(z_0);
ro.absorb(z_i);
let _ = U.absorb_in_ro(cs.namespace(|| "absorb U"), &mut ro)?;
U.absorb_in_ro(cs.namespace(|| "absorb U"), &mut ro)?;
let hash_bits = ro.get_hash(cs.namespace(|| "Input hash"))?;
let hash = le_bits_to_num(cs.namespace(|| "bits to hash"), hash_bits)?;
@@ -332,15 +332,14 @@ where
ro.absorb(i_new.clone());
ro.absorb(z_0);
ro.absorb(z_next);
let _ = Unew.absorb_in_ro(cs.namespace(|| "absorb U_new"), &mut ro)?;
Unew.absorb_in_ro(cs.namespace(|| "absorb U_new"), &mut ro)?;
let hash_bits = ro.get_hash(cs.namespace(|| "output hash bits"))?;
let hash = le_bits_to_num(cs.namespace(|| "convert hash to num"), hash_bits)?;
// Outputs the computed hash and u.X[1] that corresponds to the hash of the other circuit
let _ = u
.X1
u.X1
.inputize(cs.namespace(|| "Output unmodified hash of the other circuit"))?;
let _ = hash.inputize(cs.namespace(|| "output new hash of this circuit"))?;
hash.inputize(cs.namespace(|| "output new hash of this circuit"))?;
Ok(())
}

View File

@@ -740,7 +740,7 @@ mod tests {
CS: ConstraintSystem<Fp>,
{
let a = AllocatedPoint::<Fp>::random_vartime(cs.namespace(|| "a")).unwrap();
let _ = a.inputize(cs.namespace(|| "inputize a")).unwrap();
a.inputize(cs.namespace(|| "inputize a")).unwrap();
let s = Fq::random(&mut OsRng);
// Allocate random bits and only keep 128 bits
let bits: Vec<AllocatedBit> = s
@@ -751,7 +751,7 @@ mod tests {
.collect::<Result<Vec<AllocatedBit>, SynthesisError>>()
.unwrap();
let e = a.scalar_mul(cs.namespace(|| "Scalar Mul"), bits).unwrap();
let _ = e.inputize(cs.namespace(|| "inputize e")).unwrap();
e.inputize(cs.namespace(|| "inputize e")).unwrap();
(a, e, s)
}
@@ -792,9 +792,9 @@ mod tests {
CS: ConstraintSystem<Fp>,
{
let a = AllocatedPoint::<Fp>::random_vartime(cs.namespace(|| "a")).unwrap();
let _ = a.inputize(cs.namespace(|| "inputize a")).unwrap();
a.inputize(cs.namespace(|| "inputize a")).unwrap();
let e = a.add(cs.namespace(|| "add a to a"), &a).unwrap();
let _ = e.inputize(cs.namespace(|| "inputize e")).unwrap();
e.inputize(cs.namespace(|| "inputize e")).unwrap();
(a, e)
}
@@ -834,11 +834,11 @@ mod tests {
CS: ConstraintSystem<Fp>,
{
let a = AllocatedPoint::<Fp>::random_vartime(cs.namespace(|| "a")).unwrap();
let _ = a.inputize(cs.namespace(|| "inputize a")).unwrap();
a.inputize(cs.namespace(|| "inputize a")).unwrap();
let mut b = a.clone();
b.y =
AllocatedNum::alloc(cs.namespace(|| "allocate negation of a"), || Ok(Fp::zero())).unwrap();
let _ = b.inputize(cs.namespace(|| "inputize b")).unwrap();
b.inputize(cs.namespace(|| "inputize b")).unwrap();
let e = a.add(cs.namespace(|| "add a to b"), &b).unwrap();
e
}

View File

@@ -244,7 +244,7 @@ mod tests {
ro.absorb(num);
let num_gadget =
AllocatedNum::alloc(cs.namespace(|| format!("data {}", i)), || Ok(num)).unwrap();
let _ = num_gadget
num_gadget
.inputize(&mut cs.namespace(|| format!("input {}", i)))
.unwrap();
ro_gadget.absorb(num_gadget);