Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kilic committed Jan 7, 2024
1 parent e6861b0 commit bfcfa79
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 102 deletions.
4 changes: 2 additions & 2 deletions halo2_proofs/benches/dev_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn criterion_benchmark(c: &mut Criterion) {
|mut table| {
for row in 0u64..(1 << 8) {
table.assign_cell(
|| format!("row {}", row),
|| format!("row {row}"),
config.table,
row as usize,
|| Value::known(F::from(row + 1)),
Expand All @@ -79,7 +79,7 @@ fn criterion_benchmark(c: &mut Criterion) {
for offset in 0u64..(1 << 10) {
config.selector.enable(&mut region, offset as usize)?;
region.assign_advice(
|| format!("offset {}", offset),
|| format!("offset {offset}"),
config.advice,
offset as usize,
|| Value::known(F::from((offset % 256) + 1)),
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/examples/circuit-layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<F: Field> Circuit<F> for MyCircuit<F> {

for i in 0..10 {
layouter.assign_region(
|| format!("region_{}", i),
|| format!("region_{i}"),
|mut region| {
let a: Value<Assigned<_>> = self.a.into();
let mut a_squared = Value::unknown();
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/examples/proof-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Circuit<Fp> for TestCircuit {
|mut table| {
for row in 0u64..(1 << 8) {
table.assign_cell(
|| format!("row {}", row),
|| format!("row {row}"),
config.table,
row as usize,
|| Value::known(Fp::from(row + 1)),
Expand All @@ -70,7 +70,7 @@ impl Circuit<Fp> for TestCircuit {
for offset in 0u64..(1 << 10) {
config.selector.enable(&mut region, offset as usize)?;
region.assign_advice(
|| format!("offset {}", offset),
|| format!("offset {offset}"),
config.advice,
offset as usize,
|| Value::known(Fp::from((offset % 256) + 1)),
Expand Down
11 changes: 3 additions & 8 deletions halo2_proofs/examples/shuffle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<F: Field, const W: usize, const H: usize> Circuit<F> for MyCircuit<F, W, H>
{
for (offset, &value) in values.transpose_array().iter().enumerate() {
region.assign_advice(
|| format!("original[{}][{}]", idx, offset),
|| format!("original[{idx}][{offset}]"),
column,
offset,
|| value,
Expand All @@ -183,7 +183,7 @@ impl<F: Field, const W: usize, const H: usize> Circuit<F> for MyCircuit<F, W, H>
{
for (offset, &value) in values.transpose_array().iter().enumerate() {
region.assign_advice(
|| format!("shuffled[{}][{}]", idx, offset),
|| format!("shuffled[{idx}][{offset}]"),
column,
offset,
|| value,
Expand Down Expand Up @@ -233,12 +233,7 @@ impl<F: Field, const W: usize, const H: usize> Circuit<F> for MyCircuit<F, W, H>
},
);
for (offset, value) in z.transpose_vec(H + 1).into_iter().enumerate() {
region.assign_advice(
|| format!("z[{}]", offset),
config.z,
offset,
|| value,
)?;
region.assign_advice(|| format!("z[{offset}]"), config.z, offset, || value)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl<'a, F: Field, L: Layouter<F> + 'a> Drop for NamespacedLayouter<'a, F, L> {
if is_second_frame {
// Resolve this instruction pointer to a symbol name.
backtrace::resolve_frame(frame, |symbol| {
gadget_name = symbol.name().map(|name| format!("{:#}", name));
gadget_name = symbol.name().map(|name| format!("{name:#}"));
});

// We are done!
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/circuit/table_layouter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> TableLayouter<F>
return Err(Error::TableError(TableError::OverwriteDefault(
column,
format!("{:?}", entry.0.unwrap()),
format!("{:?}", value),
format!("{value:?}"),
)))
}
_ => (),
Expand Down
8 changes: 4 additions & 4 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,12 @@ impl<F: FromUniformBytes<64> + Ord> MockProver<F> {
// check all the row ids are valid
for row_id in gate_row_ids.clone() {
if !self.usable_rows.contains(&row_id) {
panic!("invalid gate row id {}", row_id)
panic!("invalid gate row id {row_id}")
}
}
for row_id in lookup_input_row_ids.clone() {
if !self.usable_rows.contains(&row_id) {
panic!("invalid lookup row id {}", row_id)
panic!("invalid lookup row id {row_id}")
}
}

Expand Down Expand Up @@ -1196,12 +1196,12 @@ impl<F: FromUniformBytes<64> + Ord> MockProver<F> {
// check all the row ids are valid
gate_row_ids.par_iter().for_each(|row_id| {
if !self.usable_rows.contains(row_id) {
panic!("invalid gate row id {}", row_id);
panic!("invalid gate row id {row_id}");
}
});
lookup_input_row_ids.par_iter().for_each(|row_id| {
if !self.usable_rows.contains(row_id) {
panic!("invalid gate row id {}", row_id);
panic!("invalid gate row id {row_id}");
}
});

Expand Down
68 changes: 32 additions & 36 deletions halo2_proofs/src/dev/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pub enum FailureLocation {
impl fmt::Display for FailureLocation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InRegion { region, offset } => write!(f, "in {} at offset {}", region, offset),
Self::InRegion { region, offset } => write!(f, "in {region} at offset {offset}"),
Self::OutsideRegion { row } => {
write!(f, "outside any region, on row {}", row)
write!(f, "outside any region, on row {row}")
}
}
}
Expand Down Expand Up @@ -248,16 +248,15 @@ impl fmt::Display for VerifyFailure {
} => {
write!(
f,
"{} uses {} at offset {}, which requires cell in instance column {:?} at row {} to be assigned.",
region, gate, gate_offset, column, row
"{region} uses {gate} at offset {gate_offset}, which requires cell in instance column {column:?} at row {row} to be assigned.",
)
}
Self::ConstraintNotSatisfied {
constraint,
location,
cell_values,
} => {
writeln!(f, "{} is not satisfied {}", constraint, location)?;
writeln!(f, "{constraint} is not satisfied {location}")?;
for (dvc, value) in cell_values.iter().map(|(vc, string)| {
let ann_map = match location {
FailureLocation::InRegion { region, offset: _ } => {
Expand All @@ -268,15 +267,14 @@ impl fmt::Display for VerifyFailure {

(DebugVirtualCell::from((vc, ann_map.as_ref())), string)
}) {
writeln!(f, "- {} = {}", dvc, value)?;
writeln!(f, "- {dvc} = {value}")?;
}
Ok(())
}
Self::ConstraintPoisoned { constraint } => {
write!(
f,
"{} is active on an unusable row - missing selector?",
constraint
"{constraint} is active on an unusable row - missing selector?"
)
}
Self::Lookup {
Expand All @@ -286,8 +284,7 @@ impl fmt::Display for VerifyFailure {
} => {
write!(
f,
"Lookup {}(index: {}) is not satisfied {}",
name, lookup_index, location
"Lookup {name}(index: {lookup_index}) is not satisfied {location}",
)
}
Self::Shuffle {
Expand All @@ -297,8 +294,7 @@ impl fmt::Display for VerifyFailure {
} => {
write!(
f,
"Shuffle {}(index: {}) is not satisfied {}",
name, shuffle_index, location
"Shuffle {name}(index: {shuffle_index}) is not satisfied {location}"
)
}
Self::Permutation { column, location } => {
Expand Down Expand Up @@ -350,9 +346,9 @@ impl Debug for VerifyFailure {
.collect(),
};

write!(f, "{:#?}", debug)
write!(f, "{debug:#?}")
}
_ => write!(f, "{:#}", self),
_ => write!(f, "{self:#}"),
}
}
}
Expand Down Expand Up @@ -394,7 +390,7 @@ fn render_cell_not_assigned<F: Field>(
if cell.column == column && gate_offset as i32 + cell.rotation.0 == offset as i32 {
"X".to_string()
} else {
format!("x{}", i)
format!("x{i}")
}
});
}
Expand Down Expand Up @@ -456,7 +452,7 @@ fn render_constraint_not_satisfied<F: Field>(
.entry(cell.rotation)
.or_default()
.entry(cell.column)
.or_insert(format!("x{}", i));
.or_insert(format!("x{i}"));
}

eprintln!("error: constraint not satisfied");
Expand All @@ -481,7 +477,7 @@ fn render_constraint_not_satisfied<F: Field>(
eprintln!();
eprintln!(" Assigned cell values:");
for (i, (_, value)) in cell_values.iter().enumerate() {
eprintln!(" x{} = {}", i, value);
eprintln!(" x{i} = {value}");
}
}

Expand Down Expand Up @@ -526,7 +522,7 @@ fn render_lookup<F: Field>(
// expressions for the table side of lookups.
let lookup_columns = lookup.table_expressions.iter().map(|expr| {
expr.evaluate(
&|f| format! {"Const: {:#?}", f},
&|f| format! {"Const: {f:#?}"},
&|s| format! {"S{}", s.0},
&|query| {
format!(
Expand Down Expand Up @@ -562,10 +558,10 @@ fn render_lookup<F: Field>(
)
},
&|challenge| format! {"C{}", challenge.index()},
&|query| format! {"-{}", query},
&|a, b| format! {"{} + {}", a,b},
&|a, b| format! {"{} * {}", a,b},
&|a, b| format! {"{} * {:?}", a, b},
&|query| format! {"-{query}"},
&|a, b| format! {"{a} + {b}"},
&|a, b| format! {"{a} * {b}"},
&|a, b| format! {"{a} * {b:?}"},
)
});

Expand Down Expand Up @@ -604,7 +600,7 @@ fn render_lookup<F: Field>(
eprintln!(")");

eprintln!();
eprintln!(" Lookup '{}' inputs:", name);
eprintln!(" Lookup '{name}' inputs:");
for (i, input) in lookup.input_expressions.iter().enumerate() {
// Fetch the cell values (since we don't store them in VerifyFailure::Lookup).
let cell_values = input.evaluate(
Expand Down Expand Up @@ -643,7 +639,7 @@ fn render_lookup<F: Field>(
.entry(cell.rotation)
.or_default()
.entry(cell.column)
.or_insert(format!("x{}", i));
.or_insert(format!("x{i}"));
}

if i != 0 {
Expand All @@ -658,15 +654,15 @@ fn render_lookup<F: Field>(

emitter::render_cell_layout(" | ", location, &columns, &layout, |_, rotation| {
if rotation == 0 {
eprint!(" <--{{ Lookup '{}' inputs queried here", name);
eprint!(" <--{{ Lookup '{name}' inputs queried here");
}
});

// Print the map from local variables to assigned values.
eprintln!(" |");
eprintln!(" | Assigned cell values:");
for (i, (_, value)) in cell_values.iter().enumerate() {
eprintln!(" | x{} = {}", i, value);
eprintln!(" | x{i} = {value}");
}
}
}
Expand All @@ -692,7 +688,7 @@ fn render_shuffle<F: Field>(

let shuffle_columns = shuffle.shuffle_expressions.iter().map(|expr| {
expr.evaluate(
&|f| format! {"Const: {:#?}", f},
&|f| format! {"Const: {f:#?}"},
&|s| format! {"S{}", s.0},
&|query| {
format!(
Expand Down Expand Up @@ -728,10 +724,10 @@ fn render_shuffle<F: Field>(
)
},
&|challenge| format! {"C{}", challenge.index()},
&|query| format! {"-{}", query},
&|a, b| format! {"{} + {}", a,b},
&|a, b| format! {"{} * {}", a,b},
&|a, b| format! {"{} * {:?}", a, b},
&|query| format! {"-{query}"},
&|a, b| format! {"{a} + {b}"},
&|a, b| format! {"{a} * {b}"},
&|a, b| format! {"{a} * {b:?}"},
)
});

Expand Down Expand Up @@ -769,7 +765,7 @@ fn render_shuffle<F: Field>(
eprintln!(")");

eprintln!();
eprintln!(" Shuffle '{}' inputs:", name);
eprintln!(" Shuffle '{name}' inputs:");
for (i, input) in shuffle.input_expressions.iter().enumerate() {
// Fetch the cell values (since we don't store them in VerifyFailure::Shuffle).
let cell_values = input.evaluate(
Expand Down Expand Up @@ -808,7 +804,7 @@ fn render_shuffle<F: Field>(
.entry(cell.rotation)
.or_default()
.entry(cell.column)
.or_insert(format!("x{}", i));
.or_insert(format!("x{i}"));
}

if i != 0 {
Expand All @@ -823,15 +819,15 @@ fn render_shuffle<F: Field>(

emitter::render_cell_layout(" | ", location, &columns, &layout, |_, rotation| {
if rotation == 0 {
eprint!(" <--{{ Shuffle '{}' inputs queried here", name);
eprint!(" <--{{ Shuffle '{name}' inputs queried here");
}
});

// Print the map from local variables to assigned values.
eprintln!(" |");
eprintln!(" | Assigned cell values:");
for (i, (_, value)) in cell_values.iter().enumerate() {
eprintln!(" | x{} = {}", i, value);
eprintln!(" | x{i} = {value}");
}
}
}
Expand Down Expand Up @@ -871,7 +867,7 @@ impl VerifyFailure {
shuffle_index,
location,
} => render_shuffle(prover, name, *shuffle_index, location),
_ => eprintln!("{}", self),
_ => eprintln!("{self}"),
}
}
}
Loading

0 comments on commit bfcfa79

Please sign in to comment.