Skip to content

Commit

Permalink
Re-enable non-inlined format args (#1362)
Browse files Browse the repository at this point in the history
Fixes #1360
  • Loading branch information
chriseth authored May 8, 2024
1 parent dee6693 commit 62c3ead
Show file tree
Hide file tree
Showing 54 changed files with 144 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ codegen-units = 256

[profile.release-with-debug]
inherits = "release"
debug = true
debug = true
3 changes: 3 additions & 0 deletions airgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ powdr-number = { path = "../number" }
powdr-analysis = { path = "../analysis" }

log = "0.4.17"

[lints.clippy]
uninlined_format_args = "deny"
3 changes: 3 additions & 0 deletions analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ env_logger = "0.10.0"

[package.metadata.cargo-udeps.ignore]
development = ["env_logger"]

[lints.clippy]
uninlined_format_args = "deny"
20 changes: 7 additions & 13 deletions analysis/src/machine_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ impl TypeChecker {
if let Some(using_reg) = &using_reg {
if using_reg.len() != lhs.len() {
errors.push(format!(
"Mismatched number of registers for assignment {}",
statement_string
"Mismatched number of registers for assignment {statement_string}"
));
}
}
Expand Down Expand Up @@ -177,8 +176,7 @@ impl TypeChecker {
let operation_count = callable.operation_definitions().count();
if operation_count > 0 && latch.is_none() {
errors.push(format!(
"Machine {} should have a latch column as it does not have a pc and has operations",
ctx
"Machine {ctx} should have a latch column as it does not have a pc and has operations"
));
}

Expand All @@ -195,8 +193,7 @@ impl TypeChecker {
// no operation id column
if operation_count > 1 {
errors.push(format!(
"Machine {} should have an operation id column as it does not have a pc and has more than one operation",
ctx
"Machine {ctx} should have an operation id column as it does not have a pc and has more than one operation"
));
}
if let Some(o) = callable.operation_definitions().next() {
Expand Down Expand Up @@ -232,20 +229,17 @@ impl TypeChecker {
} else {
if latch.is_some() {
errors.push(format!(
"Machine {} should not have a latch column as it has a pc",
ctx
"Machine {ctx} should not have a latch column as it has a pc"
));
}
if operation_id.is_some() {
errors.push(format!(
"Machine {} should not have an operation id column as it has a pc",
ctx
"Machine {ctx} should not have an operation id column as it has a pc"
));
}
if call_selectors.is_some() {
errors.push(format!(
"Machine {} should not have call_selectors as it has a pc",
ctx
"Machine {ctx} should not have call_selectors as it has a pc"
));
}
for l in &links {
Expand All @@ -263,7 +257,7 @@ impl TypeChecker {
}

if registers.iter().filter(|r| r.ty.is_pc()).count() > 1 {
errors.push(format!("Machine {} cannot have more than one pc", ctx));
errors.push(format!("Machine {ctx} cannot have more than one pc"));
}

let machine = Machine {
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/vm/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn infer_machine(mut machine: Machine) -> Result<Machine, Vec<String>> {
.instructions
.iter()
.find(|i| i.name == *instr_name)
.unwrap_or_else(|| panic!("invalid instruction: {}", instr_name));
.unwrap_or_else(|| panic!("invalid instruction: {instr_name}"));

def.instruction
.params
Expand Down
3 changes: 3 additions & 0 deletions asm-to-pil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ pretty_assertions = "1.4.0"
[dev-dependencies]
powdr-analysis = { path = "../analysis" }
powdr-importer = { path = "../importer" }

[lints.clippy]
uninlined_format_args = "deny"
4 changes: 2 additions & 2 deletions asm-to-pil/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ fn output_registers(count: usize) -> Vec<String> {

/// The name of the read-only registers at index `i`
pub fn input_at(i: usize) -> String {
format!("_input_{}", i)
format!("_input_{i}")
}

/// The name of the output assignment registers at index `i`
pub fn output_at(i: usize) -> String {
format!("_output_{}", i)
format!("_output_{i}")
}

/// The return instruction for `output_count` outputs and `pc_name` the name of the pc
Expand Down
2 changes: 1 addition & 1 deletion asm-to-pil/src/romgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn generate_machine_rom<T: FieldElement>(mut machine: Machine) -> (Machine,
.first_mut()
.expect("function should have at least one statement as it must return")
.statements
.insert(0, parse_function_statement(&format!("_{}:", name)));
.insert(0, parse_function_statement(&format!("_{name}:")));

// modify the last batch to be caused by the coming label
let last = batches
Expand Down
16 changes: 7 additions & 9 deletions asm-to-pil/src/vm_to_constrained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T: FieldElement> VMConverter<T> {
Pc => {
// introduce an intermediate witness polynomial to keep the degree of polynomial identities at 2
// this may not be optimal for backends which support higher degree constraints
let pc_update_name = format!("{}_update", name);
let pc_update_name = format!("{name}_update");

vec![
PilStatement::PolynomialDefinition(
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<T: FieldElement> VMConverter<T> {
Input::Literal(param.name, LiteralKind::UnsignedConstant)
}
None => Input::Register(param.name),
Some(ty) => panic!("Invalid param type {}", ty),
Some(ty) => panic!("Invalid param type {ty}"),
})
.collect();

Expand Down Expand Up @@ -406,7 +406,7 @@ impl<T: FieldElement> VMConverter<T> {
);
}
}
Some(ty) => panic!("Invalid param type '{}'", ty),
Some(ty) => panic!("Invalid param type '{ty}'"),
}
}

Expand Down Expand Up @@ -556,8 +556,7 @@ impl<T: FieldElement> VMConverter<T> {
for name in &rhs_assignment_registers {
assert!(
lhs.inputs_and_outputs().any(|p_lhs| p_lhs.name == *name),
"Assignment register '{}' used on rhs must be present on lhs params",
name
"Assignment register '{name}' used on rhs must be present on lhs params"
);
}

Expand Down Expand Up @@ -645,8 +644,7 @@ impl<T: FieldElement> VMConverter<T> {
assert_eq!(
instr.inputs.len() + instr.outputs.len(),
args.len(),
"Called instruction {} with the wrong number of arguments",
instr_name
"Called instruction {instr_name} with the wrong number of arguments"
);

let mut args = args.into_iter();
Expand Down Expand Up @@ -679,7 +677,7 @@ impl<T: FieldElement> VMConverter<T> {
T::from(n),
));
} else {
panic!("expected unsigned number, received {}", a);
panic!("expected unsigned number, received {a}");
}
}
Input::Literal(_, LiteralKind::SignedConstant) => {
Expand Down Expand Up @@ -1103,7 +1101,7 @@ impl<T: FieldElement> VMConverter<T> {
if counter == 0 {
"".to_string()
} else {
format!("_{}", counter)
format!("_{counter}")
}
);
self.pil.push(PilStatement::PolynomialDefinition(
Expand Down
3 changes: 3 additions & 0 deletions asm-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ repository = { workspace = true }

[dependencies]
itertools = "^0.10"

[lints.clippy]
uninlined_format_args = "deny"
4 changes: 2 additions & 2 deletions asm-utils/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<F: FunctionOpKind> Display for Expression<F> {
match self {
Expression::Number(n) => write!(f, "{n}"),
Expression::Symbol(sym) => write!(f, "{sym}"),
Expression::UnaryOp(kind, expr) => write!(f, "({}{})", kind, expr),
Expression::UnaryOp(kind, expr) => write!(f, "({kind}{expr})"),
Expression::BinaryOp(op, args) => {
let symbol = match op {
BinaryOpKind::Or => "|",
Expand All @@ -180,7 +180,7 @@ impl<F: FunctionOpKind> Display for Expression<F> {
};
write!(f, "({} {symbol} {})", args[0], args[1])
}
Expression::FunctionOp(kind, expr) => write!(f, "{}({})", kind, expr),
Expression::FunctionOp(kind, expr) => write!(f, "{kind}({expr})"),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ auto_enums = "0.8.5"
[dev-dependencies]
pretty_assertions = "1.4.0"

[lints.clippy]
uninlined_format_args = "deny"
4 changes: 2 additions & 2 deletions ast/src/analyzed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ impl<T: FieldElement> Analyzed<T> {
}

pub fn serialize(&self) -> Result<Vec<u8>, String> {
serde_cbor::to_vec(self).map_err(|e| format!("Failed to serialize analyzed: {}", e))
serde_cbor::to_vec(self).map_err(|e| format!("Failed to serialize analyzed: {e}"))
}

pub fn deserialize(bytes: &[u8]) -> Result<Self, String> {
serde_cbor::from_slice(bytes).map_err(|e| format!("Failed to deserialize analyzed: {}", e))
serde_cbor::from_slice(bytes).map_err(|e| format!("Failed to deserialize analyzed: {e}"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ast/src/asm_analysis/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl Display for FunctionBody {

impl Display for Incompatible {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

Expand Down
4 changes: 2 additions & 2 deletions ast/src/object/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Display for PILGraph {
}
}
for (location, object) in &self.objects {
writeln!(f, "// Object {}", location)?;
writeln!(f, "// Object {location}")?;
writeln!(f, "{object}")?;
writeln!(f)?;
}
Expand All @@ -41,7 +41,7 @@ impl Display for PILGraph {
impl Display for Object {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(degree) = self.degree.as_ref() {
writeln!(f, "// Degree {}", degree)?;
writeln!(f, "// Degree {degree}")?;
}
for s in &self.pil {
writeln!(f, "{s}")?;
Expand Down
8 changes: 4 additions & 4 deletions ast/src/parsed/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn format_instruction_statement(stmt: &PilStatement) -> String {
assert_eq!(s.pop(), Some(';'));
s
}
_ => panic!("invalid statement inside instruction body: {}", stmt),
_ => panic!("invalid statement inside instruction body: {stmt}"),
}
}

Expand Down Expand Up @@ -204,7 +204,7 @@ impl Display for MachineStatement {
.unwrap_or_default()
),
MachineStatement::InstructionDeclaration(_, name, instruction) => {
write!(f, "instr {}{}", name, instruction)
write!(f, "instr {name}{instruction}")
}
MachineStatement::LinkDeclaration(_, link) => {
write!(f, "{link}")
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Display for Param {
.unwrap_or_default(),
self.ty
.as_ref()
.map(|ty| format!(": {}", ty))
.map(|ty| format!(": {ty}"))
.unwrap_or_default()
)
}
Expand Down Expand Up @@ -595,7 +595,7 @@ impl<Ref: Display> Display for Expression<Ref> {
Expression::Number(value, _) => write!(f, "{value}"),
Expression::String(value) => write!(f, "{}", quote(value)),
Expression::Tuple(items) => write!(f, "({})", format_list(items)),
Expression::LambdaExpression(lambda) => write!(f, "{}", lambda),
Expression::LambdaExpression(lambda) => write!(f, "{lambda}"),
Expression::ArrayLiteral(array) => write!(f, "{array}"),
Expression::BinaryOperation(left, op, right) => write!(f, "({left} {op} {right})"),
Expression::UnaryOperation(op, exp) => {
Expand Down
3 changes: 3 additions & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ pretty_assertions = "1.4.0"

[package.metadata.cargo-udeps.ignore]
development = ["env_logger"]

[lints.clippy]
uninlined_format_args = "deny"
2 changes: 1 addition & 1 deletion backend/src/halo2/circuit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<'a, T: FieldElement, F: PrimeField<Repr = [u8; 32]>> Circuit<F> for PowdrCi
0 => meta.advice_column_in(FirstPhase),
1 => meta.advice_column_in(SecondPhase),
2 => meta.advice_column_in(ThirdPhase),
_ => panic!("Stage too large for Halo2 backend: {}", stage),
_ => panic!("Stage too large for Halo2 backend: {stage}"),
};
(name.clone(), col)
})
Expand Down
3 changes: 3 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ env_logger = "0.10.0"
[[bin]]
name = "powdr"
path = "src/main.rs"

[lints.clippy]
uninlined_format_args = "deny"
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ fn run_command(command: Commands) {
};
if let Err(errors) = result {
for error in errors {
eprintln!("{}", error);
eprintln!("{error}");
}
std::process::exit(1);
}
Expand Down
3 changes: 3 additions & 0 deletions executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ pretty_assertions = "1.4.0"

[package.metadata.cargo-udeps.ignore]
development = ["env_logger"]

[lints.clippy]
uninlined_format_args = "deny"
2 changes: 1 addition & 1 deletion executor/src/constant_evaluator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn generate_values<T: FieldElement>(
assert!(index.is_some());
assert_eq!(base.as_ref(), &Type::Col);
} else {
panic!("Invalid fixed column type: {}", ty);
panic!("Invalid fixed column type: {ty}");
}
};
let index_expr;
Expand Down
8 changes: 4 additions & 4 deletions executor/src/witgen/data_structures/finalizable_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a, T: FieldElement> FinalizableData<'a, T> {
pub fn remove(&mut self, i: usize) -> Row<'a, T> {
match self.data.remove(i) {
Entry::InProgress(row) => row,
Entry::Finalized(_, _) => panic!("Row {} already finalized.", i),
Entry::Finalized(_, _) => panic!("Row {i} already finalized."),
}
}

Expand All @@ -86,7 +86,7 @@ impl<'a, T: FieldElement> FinalizableData<'a, T> {
pub fn get_mut(&mut self, i: usize) -> Option<&mut Row<'a, T>> {
match &mut self.data[i] {
Entry::InProgress(row) => Some(row),
Entry::Finalized(_, _) => panic!("Row {} already finalized.", i),
Entry::Finalized(_, _) => panic!("Row {i} already finalized."),
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ impl<'a, T: FieldElement> Index<usize> for FinalizableData<'a, T> {
fn index(&self, index: usize) -> &Self::Output {
match &self.data[index] {
Entry::InProgress(row) => row,
Entry::Finalized(_, _) => panic!("Row {} already finalized.", index),
Entry::Finalized(_, _) => panic!("Row {index} already finalized."),
}
}
}
Expand All @@ -192,7 +192,7 @@ impl<'a, T: FieldElement> IndexMut<usize> for FinalizableData<'a, T> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
match &mut self.data[index] {
Entry::InProgress(row) => row,
Entry::Finalized(_, _) => panic!("Row {} already finalized.", index),
Entry::Finalized(_, _) => panic!("Row {index} already finalized."),
}
}
}
2 changes: 1 addition & 1 deletion executor/src/witgen/eval_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<T: FieldElement> fmt::Display for EvalError<T> {
EvalError::FixedLookupFailed(input_assignment) => {
let query = input_assignment
.iter()
.map(|(poly_name, v)| format!("{} = {}", poly_name, v))
.map(|(poly_name, v)| format!("{poly_name} = {v}"))
.collect::<Vec<_>>()
.join(", ");
write!(
Expand Down
Loading

0 comments on commit 62c3ead

Please sign in to comment.