diff --git a/halo2_proofs/benches/dev_lookup.rs b/halo2_proofs/benches/dev_lookup.rs index 62ed5a7f19..569ffd1019 100644 --- a/halo2_proofs/benches/dev_lookup.rs +++ b/halo2_proofs/benches/dev_lookup.rs @@ -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)), @@ -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)), diff --git a/halo2_proofs/examples/circuit-layout.rs b/halo2_proofs/examples/circuit-layout.rs index 18de27a783..b65adf5599 100644 --- a/halo2_proofs/examples/circuit-layout.rs +++ b/halo2_proofs/examples/circuit-layout.rs @@ -245,7 +245,7 @@ impl Circuit for MyCircuit { for i in 0..10 { layouter.assign_region( - || format!("region_{}", i), + || format!("region_{i}"), |mut region| { let a: Value> = self.a.into(); let mut a_squared = Value::unknown(); diff --git a/halo2_proofs/examples/proof-size.rs b/halo2_proofs/examples/proof-size.rs index f2b3cf7322..3d5b242fb0 100644 --- a/halo2_proofs/examples/proof-size.rs +++ b/halo2_proofs/examples/proof-size.rs @@ -53,7 +53,7 @@ impl Circuit 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)), @@ -70,7 +70,7 @@ impl Circuit 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)), diff --git a/halo2_proofs/examples/shuffle.rs b/halo2_proofs/examples/shuffle.rs index 17bbb3330a..35a85cb9f0 100644 --- a/halo2_proofs/examples/shuffle.rs +++ b/halo2_proofs/examples/shuffle.rs @@ -168,7 +168,7 @@ impl Circuit for MyCircuit { for (offset, &value) in values.transpose_array().iter().enumerate() { region.assign_advice( - || format!("original[{}][{}]", idx, offset), + || format!("original[{idx}][{offset}]"), column, offset, || value, @@ -183,7 +183,7 @@ impl Circuit for MyCircuit { for (offset, &value) in values.transpose_array().iter().enumerate() { region.assign_advice( - || format!("shuffled[{}][{}]", idx, offset), + || format!("shuffled[{idx}][{offset}]"), column, offset, || value, @@ -233,12 +233,7 @@ impl Circuit for MyCircuit }, ); 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(()) diff --git a/halo2_proofs/src/circuit.rs b/halo2_proofs/src/circuit.rs index 3fab93997c..56a6be0e5c 100644 --- a/halo2_proofs/src/circuit.rs +++ b/halo2_proofs/src/circuit.rs @@ -572,7 +572,7 @@ impl<'a, F: Field, L: Layouter + '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! diff --git a/halo2_proofs/src/circuit/table_layouter.rs b/halo2_proofs/src/circuit/table_layouter.rs index 5efe11735c..06338bb896 100644 --- a/halo2_proofs/src/circuit/table_layouter.rs +++ b/halo2_proofs/src/circuit/table_layouter.rs @@ -103,7 +103,7 @@ impl<'r, 'a, F: Field, CS: Assignment + 'a> TableLayouter return Err(Error::TableError(TableError::OverwriteDefault( column, format!("{:?}", entry.0.unwrap()), - format!("{:?}", value), + format!("{value:?}"), ))) } _ => (), diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 48dcca5ba0..894686e92c 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -753,12 +753,12 @@ impl + Ord> MockProver { // 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}") } } @@ -1196,12 +1196,12 @@ impl + Ord> MockProver { // 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}"); } }); diff --git a/halo2_proofs/src/dev/failure.rs b/halo2_proofs/src/dev/failure.rs index 38b5b0ea61..f9f5c27ded 100644 --- a/halo2_proofs/src/dev/failure.rs +++ b/halo2_proofs/src/dev/failure.rs @@ -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}") } } } @@ -248,8 +248,7 @@ 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 { @@ -257,7 +256,7 @@ impl fmt::Display for VerifyFailure { 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: _ } => { @@ -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 { @@ -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 { @@ -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 } => { @@ -350,9 +346,9 @@ impl Debug for VerifyFailure { .collect(), }; - write!(f, "{:#?}", debug) + write!(f, "{debug:#?}") } - _ => write!(f, "{:#}", self), + _ => write!(f, "{self:#}"), } } } @@ -394,7 +390,7 @@ fn render_cell_not_assigned( if cell.column == column && gate_offset as i32 + cell.rotation.0 == offset as i32 { "X".to_string() } else { - format!("x{}", i) + format!("x{i}") } }); } @@ -456,7 +452,7 @@ fn render_constraint_not_satisfied( .entry(cell.rotation) .or_default() .entry(cell.column) - .or_insert(format!("x{}", i)); + .or_insert(format!("x{i}")); } eprintln!("error: constraint not satisfied"); @@ -481,7 +477,7 @@ fn render_constraint_not_satisfied( eprintln!(); eprintln!(" Assigned cell values:"); for (i, (_, value)) in cell_values.iter().enumerate() { - eprintln!(" x{} = {}", i, value); + eprintln!(" x{i} = {value}"); } } @@ -526,7 +522,7 @@ fn render_lookup( // 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!( @@ -562,10 +558,10 @@ fn render_lookup( ) }, &|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:?}"}, ) }); @@ -604,7 +600,7 @@ fn render_lookup( 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( @@ -643,7 +639,7 @@ fn render_lookup( .entry(cell.rotation) .or_default() .entry(cell.column) - .or_insert(format!("x{}", i)); + .or_insert(format!("x{i}")); } if i != 0 { @@ -658,7 +654,7 @@ fn render_lookup( emitter::render_cell_layout(" | ", location, &columns, &layout, |_, rotation| { if rotation == 0 { - eprint!(" <--{{ Lookup '{}' inputs queried here", name); + eprint!(" <--{{ Lookup '{name}' inputs queried here"); } }); @@ -666,7 +662,7 @@ fn render_lookup( eprintln!(" |"); eprintln!(" | Assigned cell values:"); for (i, (_, value)) in cell_values.iter().enumerate() { - eprintln!(" | x{} = {}", i, value); + eprintln!(" | x{i} = {value}"); } } } @@ -692,7 +688,7 @@ fn render_shuffle( 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!( @@ -728,10 +724,10 @@ fn render_shuffle( ) }, &|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:?}"}, ) }); @@ -769,7 +765,7 @@ fn render_shuffle( 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( @@ -808,7 +804,7 @@ fn render_shuffle( .entry(cell.rotation) .or_default() .entry(cell.column) - .or_insert(format!("x{}", i)); + .or_insert(format!("x{i}")); } if i != 0 { @@ -823,7 +819,7 @@ fn render_shuffle( emitter::render_cell_layout(" | ", location, &columns, &layout, |_, rotation| { if rotation == 0 { - eprint!(" <--{{ Shuffle '{}' inputs queried here", name); + eprint!(" <--{{ Shuffle '{name}' inputs queried here"); } }); @@ -831,7 +827,7 @@ fn render_shuffle( eprintln!(" |"); eprintln!(" | Assigned cell values:"); for (i, (_, value)) in cell_values.iter().enumerate() { - eprintln!(" | x{} = {}", i, value); + eprintln!(" | x{i} = {value}"); } } } @@ -871,7 +867,7 @@ impl VerifyFailure { shuffle_index, location, } => render_shuffle(prover, name, *shuffle_index, location), - _ => eprintln!("{}", self), + _ => eprintln!("{self}"), } } } diff --git a/halo2_proofs/src/dev/failure/emitter.rs b/halo2_proofs/src/dev/failure/emitter.rs index edd61f3060..24109d599b 100644 --- a/halo2_proofs/src/dev/failure/emitter.rs +++ b/halo2_proofs/src/dev/failure/emitter.rs @@ -53,16 +53,16 @@ pub(super) fn render_cell_layout( FailureLocation::InRegion { region, offset } => { col_headers .push_str(format!("{}Cell layout in region '{}':\n", prefix, region.name).as_str()); - col_headers.push_str(format!("{} | Offset |", prefix).as_str()); + col_headers.push_str(format!("{prefix} | Offset |").as_str()); Some(*offset as i32) } FailureLocation::OutsideRegion { row } => { - col_headers.push_str(format!("{}Cell layout at row {}:\n", prefix, row).as_str()); - col_headers.push_str(format!("{} |Rotation|", prefix).as_str()); + col_headers.push_str(format!("{prefix}Cell layout at row {row}:\n").as_str()); + col_headers.push_str(format!("{prefix} |Rotation|").as_str()); None } }; - eprint!("\n{}", col_headers); + eprint!("\n{col_headers}"); let widths: Vec = columns .iter() @@ -112,7 +112,7 @@ pub(super) fn render_cell_layout( } eprintln!(); - eprint!("{} +--------+", prefix); + eprint!("{prefix} +--------+"); for &width in widths.iter() { eprint!("{}+", padded('-', width, "")); } @@ -185,23 +185,23 @@ pub(super) fn expression_to_string( &|challenge| format!("C{}({})", challenge.index(), challenge.phase()), &|a| { if a.contains(' ') { - format!("-({})", a) + format!("-({a})") } else { - format!("-{}", a) + format!("-{a}") } }, &|a, b| { if let Some(b) = b.strip_prefix('-') { - format!("{} - {}", a, b) + format!("{a} - {b}") } else { - format!("{} + {}", a, b) + format!("{a} + {b}") } }, &|a, b| match (a.contains(' '), b.contains(' ')) { - (false, false) => format!("{} * {}", a, b), - (false, true) => format!("{} * ({})", a, b), - (true, false) => format!("({}) * {}", a, b), - (true, true) => format!("({}) * ({})", a, b), + (false, false) => format!("{a} * {b}"), + (false, true) => format!("{a} * ({b})"), + (true, false) => format!("({a}) * {b}"), + (true, true) => format!("({a}) * ({b})"), }, &|a, s| { if a.contains(' ') { diff --git a/halo2_proofs/src/dev/gates.rs b/halo2_proofs/src/dev/gates.rs index 352415bcd9..4421c0967f 100644 --- a/halo2_proofs/src/dev/gates.rs +++ b/halo2_proofs/src/dev/gates.rs @@ -146,23 +146,23 @@ impl CircuitGates { &|challenge| format!("C{}({})", challenge.index(), challenge.phase()), &|a| { if a.contains(' ') { - format!("-({})", a) + format!("-({a})") } else { - format!("-{}", a) + format!("-{a}") } }, &|a, b| { if let Some(b) = b.strip_prefix('-') { - format!("{} - {}", a, b) + format!("{a} - {b}") } else { - format!("{} + {}", a, b) + format!("{a} + {b}") } }, &|a, b| match (a.contains(' '), b.contains(' ')) { - (false, false) => format!("{} * {}", a, b), - (false, true) => format!("{} * ({})", a, b), - (true, false) => format!("({}) * {}", a, b), - (true, true) => format!("({}) * ({})", a, b), + (false, false) => format!("{a} * {b}"), + (false, true) => format!("{a} * ({b})"), + (true, false) => format!("({a}) * {b}"), + (true, true) => format!("({a}) * ({b})"), }, &|a, s| { if a.contains(' ') { @@ -264,7 +264,7 @@ impl CircuitGates { let mut ret = String::new(); let w = &mut ret; for query in &queries { - write!(w, "{},", query).unwrap(); + write!(w, "{query},").unwrap(); } writeln!(w, "Name").unwrap(); diff --git a/halo2_proofs/src/dev/graph.rs b/halo2_proofs/src/dev/graph.rs index b273940036..11654fe415 100644 --- a/halo2_proofs/src/dev/graph.rs +++ b/halo2_proofs/src/dev/graph.rs @@ -36,7 +36,7 @@ pub fn circuit_dot_graph>( .into_iter() .map(|(name, gadget_name)| { if let Some(gadget_name) = gadget_name { - format!("[{}] {}", gadget_name, name) + format!("[{gadget_name}] {name}") } else { name } diff --git a/halo2_proofs/src/dev/graph/layout.rs b/halo2_proofs/src/dev/graph/layout.rs index 7d00434aa2..94bd7eea14 100644 --- a/halo2_proofs/src/dev/graph/layout.rs +++ b/halo2_proofs/src/dev/graph/layout.rs @@ -312,7 +312,7 @@ impl CircuitLayout { root.draw( &(EmptyElement::at((0, usable_rows)) + Text::new( - format!("{} usable rows", usable_rows), + format!("{usable_rows} usable rows"), (10, 10), ("sans-serif", 15.0).into_font(), )), diff --git a/halo2_proofs/src/dev/util.rs b/halo2_proofs/src/dev/util.rs index 28489acf91..a663f9b80b 100644 --- a/halo2_proofs/src/dev/util.rs +++ b/halo2_proofs/src/dev/util.rs @@ -63,11 +63,11 @@ pub(super) fn format_value(v: F) -> String { "-1".into() } else { // Format value as hex. - let s = format!("{:?}", v); + let s = format!("{v:?}"); // Remove leading zeroes. let s = s.strip_prefix("0x").unwrap(); let s = s.trim_start_matches('0'); - format!("0x{}", s) + format!("0x{s}") } } diff --git a/halo2_proofs/src/plonk/circuit.rs b/halo2_proofs/src/plonk/circuit.rs index 98445a5881..5107554186 100644 --- a/halo2_proofs/src/plonk/circuit.rs +++ b/halo2_proofs/src/plonk/circuit.rs @@ -1110,7 +1110,7 @@ impl Expression { fn write_identifier(&self, writer: &mut W) -> std::io::Result<()> { match self { - Expression::Constant(scalar) => write!(writer, "{:?}", scalar), + Expression::Constant(scalar) => write!(writer, "{scalar:?}"), Expression::Selector(selector) => write!(writer, "selector[{}]", selector.0), Expression::Fixed(query) => { write!( @@ -1157,7 +1157,7 @@ impl Expression { } Expression::Scaled(a, f) => { a.write_identifier(writer)?; - write!(writer, "*{:?}", f) + write!(writer, "*{f:?}") } } } @@ -2206,7 +2206,7 @@ impl ConstraintSystem { if let Some(previous_phase) = phase.prev() { self.assert_phase_exists( previous_phase, - format!("Column in later phase {:?}", phase).as_str(), + format!("Column in later phase {phase:?}").as_str(), ); } @@ -2231,7 +2231,7 @@ impl ConstraintSystem { if let Some(previous_phase) = phase.prev() { self.assert_phase_exists( previous_phase, - format!("Column in later phase {:?}", phase).as_str(), + format!("Column in later phase {phase:?}").as_str(), ); } @@ -2264,7 +2264,7 @@ impl ConstraintSystem { let phase = phase.to_sealed(); self.assert_phase_exists( phase, - format!("Challenge usable after phase {:?}", phase).as_str(), + format!("Challenge usable after phase {phase:?}").as_str(), ); let tmp = Challenge { @@ -2285,8 +2285,7 @@ impl ConstraintSystem { .find(|advice_column_phase| **advice_column_phase == phase) .unwrap_or_else(|| { panic!( - "No Column is used in phase {:?} while allocating a new {:?}", - phase, resource + "No Column is used in phase {phase:?} while allocating a new {resource:?}" ) }); } diff --git a/halo2_proofs/src/plonk/error.rs b/halo2_proofs/src/plonk/error.rs index d4a7e11c14..e6caded801 100644 --- a/halo2_proofs/src/plonk/error.rs +++ b/halo2_proofs/src/plonk/error.rs @@ -63,11 +63,10 @@ impl fmt::Display for Error { Error::ConstraintSystemFailure => write!(f, "The constraint system is not satisfied"), Error::BoundsFailure => write!(f, "An out-of-bounds index was passed to the backend"), Error::Opening => write!(f, "Multi-opening proof was invalid"), - Error::Transcript(e) => write!(f, "Transcript error: {}", e), + Error::Transcript(e) => write!(f, "Transcript error: {e}"), Error::NotEnoughRowsAvailable { current_k } => write!( f, - "k = {} is too small for the given circuit. Try using a larger value of k", - current_k, + "k = {current_k} is too small for the given circuit. Try using a larger value of k", ), Error::InstanceTooLarge => write!(f, "Instance vectors are larger than the circuit"), Error::NotEnoughColumnsForConstants => { @@ -78,10 +77,9 @@ impl fmt::Display for Error { } Error::ColumnNotInPermutation(column) => write!( f, - "Column {:?} must be included in the permutation. Help: try applying `meta.enable_equalty` on the column", - column + "Column {column:?} must be included in the permutation. Help: try applying `meta.enable_equalty` on the column", ), - Error::TableError(error) => write!(f, "{}", error) + Error::TableError(error) => write!(f, "{error}") } } } @@ -114,23 +112,20 @@ impl fmt::Display for TableError { TableError::ColumnNotAssigned(col) => { write!( f, - "{:?} not fully assigned. Help: assign a value at offset 0.", - col + "{col:?} not fully assigned. Help: assign a value at offset 0.", ) } TableError::UnevenColumnLengths((col, col_len), (table, table_len)) => write!( f, - "{:?} has length {} while {:?} has length {}", - col, col_len, table, table_len + "{col:?} has length {col_len} while {table:?} has length {table_len}", ), TableError::UsedColumn(col) => { - write!(f, "{:?} has already been used", col) + write!(f, "{col:?} has already been used") } TableError::OverwriteDefault(col, default, val) => { write!( f, - "Attempted to overwrite default value {} with {} in {:?}", - default, val, col + "Attempted to overwrite default value {default} with {val} in {col:?}", ) } } diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index 307dbdfef0..28ffb399ff 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -491,7 +491,7 @@ fn plonk_api() { // Check this circuit is satisfied. let prover = match MockProver::run(K, &circuit, vec![vec![instance]]) { Ok(prover) => prover, - Err(e) => panic!("{:?}", e), + Err(e) => panic!("{e:?}"), }; assert_eq!(prover.verify(), Ok(()));