diff --git a/compiler/ast/src/expressions/call.rs b/compiler/ast/src/expressions/call.rs index 5dc8871698..f9a1e5917e 100644 --- a/compiler/ast/src/expressions/call.rs +++ b/compiler/ast/src/expressions/call.rs @@ -34,7 +34,7 @@ impl fmt::Display for CallExpression { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.external { Some(external) => { - write!(f, "{}.leo/{}(", external, self.function)?; + write!(f, "{external}.leo/{}(", self.function)?; } None => { write!(f, "{}(", self.function)?; @@ -42,7 +42,7 @@ impl fmt::Display for CallExpression { } for (i, param) in self.arguments.iter().enumerate() { - write!(f, "{}", param)?; + write!(f, "{param}")?; if i < self.arguments.len() - 1 { write!(f, ", ")?; } diff --git a/compiler/ast/src/expressions/literal.rs b/compiler/ast/src/expressions/literal.rs index aafbf1f46b..d52ee0ffde 100644 --- a/compiler/ast/src/expressions/literal.rs +++ b/compiler/ast/src/expressions/literal.rs @@ -45,13 +45,13 @@ pub enum Literal { impl fmt::Display for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self { - Self::Address(address, _) => write!(f, "{}", address), - Self::Boolean(boolean, _) => write!(f, "{}", boolean), - Self::Field(field, _) => write!(f, "{}field", field), - Self::Group(group) => write!(f, "{}group", group), - Self::Integer(type_, value, _) => write!(f, "{}{}", value, type_), - Self::Scalar(scalar, _) => write!(f, "{}scalar", scalar), - Self::String(string, _) => write!(f, "\"{}\"", string), + Self::Address(address, _) => write!(f, "{address}"), + Self::Boolean(boolean, _) => write!(f, "{boolean}"), + Self::Field(field, _) => write!(f, "{field}field"), + Self::Group(group) => write!(f, "{group}group"), + Self::Integer(type_, value, _) => write!(f, "{value}{type_}"), + Self::Scalar(scalar, _) => write!(f, "{scalar}scalar"), + Self::String(string, _) => write!(f, "\"{string}\""), } } } diff --git a/compiler/ast/src/expressions/struct_init.rs b/compiler/ast/src/expressions/struct_init.rs index 57877af087..115f349b7e 100644 --- a/compiler/ast/src/expressions/struct_init.rs +++ b/compiler/ast/src/expressions/struct_init.rs @@ -31,7 +31,7 @@ pub struct StructVariableInitializer { impl fmt::Display for StructVariableInitializer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(expr) = &self.expression { - write!(f, "{}: {}", self.identifier, expr) + write!(f, "{}: {expr}", self.identifier) } else { write!(f, "{}", self.identifier) } @@ -69,9 +69,9 @@ impl StructExpression { .map(|variable| { // Write default visibility. if variable.identifier.name == sym::_nonce { - format!("{}.public", variable) + format!("{variable}.public") } else { - format!("{}.private", variable) + format!("{variable}.private") } }) .collect::>() diff --git a/compiler/ast/src/functions/finalize.rs b/compiler/ast/src/functions/finalize.rs index 34a162e28f..80d887d7dd 100644 --- a/compiler/ast/src/functions/finalize.rs +++ b/compiler/ast/src/functions/finalize.rs @@ -71,8 +71,8 @@ impl fmt::Display for Finalize { }; write!( f, - " finalize {}({}) -> {} {}", - self.identifier, parameters, returns, self.block + " finalize {}({parameters}) -> {returns} {}", + self.identifier, self.block ) } } diff --git a/compiler/ast/src/functions/mod.rs b/compiler/ast/src/functions/mod.rs index b1cf22998b..0f26f81b7f 100644 --- a/compiler/ast/src/functions/mod.rs +++ b/compiler/ast/src/functions/mod.rs @@ -136,7 +136,7 @@ impl Function { 1 => self.output[0].to_string(), _ => self.output.iter().map(|x| x.to_string()).collect::>().join(","), }; - write!(f, "({}) -> {} {}", parameters, returns, self.block) + write!(f, "({parameters}) -> {returns} {}", self.block) } } diff --git a/compiler/ast/src/groups/group_coordinate.rs b/compiler/ast/src/groups/group_coordinate.rs index 54960bb2c0..ceb912172c 100644 --- a/compiler/ast/src/groups/group_coordinate.rs +++ b/compiler/ast/src/groups/group_coordinate.rs @@ -35,7 +35,7 @@ pub enum GroupCoordinate { impl fmt::Display for GroupCoordinate { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - GroupCoordinate::Number(number, _) => write!(f, "{}", number), + GroupCoordinate::Number(number, _) => write!(f, "{number}"), GroupCoordinate::SignHigh => write!(f, "+"), GroupCoordinate::SignLow => write!(f, "-"), GroupCoordinate::Inferred => write!(f, "_"), diff --git a/compiler/ast/src/groups/group_literal.rs b/compiler/ast/src/groups/group_literal.rs index 552a926c4e..0f488f2b19 100644 --- a/compiler/ast/src/groups/group_literal.rs +++ b/compiler/ast/src/groups/group_literal.rs @@ -48,7 +48,7 @@ impl GroupLiteral { impl fmt::Display for GroupLiteral { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Self::Single(string, _) => write!(f, "{}", string), + Self::Single(string, _) => write!(f, "{string}"), Self::Tuple(tuple) => write!(f, "{}", tuple.x), // Temporarily emit x coordinate only. } } diff --git a/compiler/ast/src/input/input_value.rs b/compiler/ast/src/input/input_value.rs index 78adbeba3e..29b8779998 100644 --- a/compiler/ast/src/input/input_value.rs +++ b/compiler/ast/src/input/input_value.rs @@ -60,11 +60,11 @@ impl TryFrom<(Type, Expression)> for InputValue { impl fmt::Display for InputValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - InputValue::Address(ref address) => write!(f, "{}", address), - InputValue::Boolean(ref boolean) => write!(f, "{}", boolean), - InputValue::Group(ref group) => write!(f, "{}", group), - InputValue::Field(ref field) => write!(f, "{}", field), - InputValue::Integer(ref type_, ref number) => write!(f, "{}{:?}", number, type_), + InputValue::Address(ref address) => write!(f, "{address}"), + InputValue::Boolean(ref boolean) => write!(f, "{boolean}"), + InputValue::Group(ref group) => write!(f, "{group}"), + InputValue::Field(ref field) => write!(f, "{field}"), + InputValue::Integer(ref type_, ref number) => write!(f, "{number}{type_:?}"), } } } diff --git a/compiler/ast/src/program/mod.rs b/compiler/ast/src/program/mod.rs index a2f02cd0a9..c5f0d6aed7 100644 --- a/compiler/ast/src/program/mod.rs +++ b/compiler/ast/src/program/mod.rs @@ -40,7 +40,7 @@ pub struct Program { impl fmt::Display for Program { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for (id, _import) in self.imports.iter() { - writeln!(f, "import {}.leo;", id)?; + writeln!(f, "import {id}.leo;")?; } for (_, program_scope) in self.program_scopes.iter() { program_scope.fmt(f)?; diff --git a/compiler/ast/src/program/program_scope.rs b/compiler/ast/src/program/program_scope.rs index f3d241e243..714d3436f1 100644 --- a/compiler/ast/src/program/program_scope.rs +++ b/compiler/ast/src/program/program_scope.rs @@ -42,13 +42,13 @@ impl fmt::Display for ProgramScope { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "program {} {{", self.program_id)?; for (_, struct_) in self.structs.iter() { - writeln!(f, " {}", struct_)?; + writeln!(f, " {struct_}")?; } for (_, mapping) in self.mappings.iter() { - writeln!(f, " {}", mapping)?; + writeln!(f, " {mapping}")?; } for (_, function) in self.functions.iter() { - writeln!(f, " {}", function)?; + writeln!(f, " {function}")?; } Ok(()) } diff --git a/compiler/ast/src/statement/block.rs b/compiler/ast/src/statement/block.rs index ac200e2798..937b65067d 100644 --- a/compiler/ast/src/statement/block.rs +++ b/compiler/ast/src/statement/block.rs @@ -37,7 +37,7 @@ impl fmt::Display for Block { } else { self.statements .iter() - .try_for_each(|statement| writeln!(f, "\t{}", statement))?; + .try_for_each(|statement| writeln!(f, "\t{statement}"))?; } write!(f, "}}") } diff --git a/compiler/ast/src/statement/conditional.rs b/compiler/ast/src/statement/conditional.rs index f9177803aa..166a902e6d 100644 --- a/compiler/ast/src/statement/conditional.rs +++ b/compiler/ast/src/statement/conditional.rs @@ -37,7 +37,7 @@ impl fmt::Display for ConditionalStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "if ({}) {}", self.condition, self.then)?; match self.otherwise.as_ref() { - Some(n_or_e) => write!(f, " else {}", n_or_e), + Some(n_or_e) => write!(f, " else {n_or_e}"), None => write!(f, ""), } } diff --git a/compiler/ast/src/statement/console/console_function.rs b/compiler/ast/src/statement/console/console_function.rs index 66d028f2e7..7735f6fa3e 100644 --- a/compiler/ast/src/statement/console/console_function.rs +++ b/compiler/ast/src/statement/console/console_function.rs @@ -33,9 +33,9 @@ pub enum ConsoleFunction { impl fmt::Display for ConsoleFunction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - ConsoleFunction::Assert(expr) => write!(f, "assert({})", expr), - ConsoleFunction::AssertEq(expr1, expr2) => write!(f, "assert_eq({}, {})", expr1, expr2), - ConsoleFunction::AssertNeq(expr1, expr2) => write!(f, "assert_neq({}, {})", expr1, expr2), + ConsoleFunction::Assert(expr) => write!(f, "assert({expr})"), + ConsoleFunction::AssertEq(expr1, expr2) => write!(f, "assert_eq({expr1}, {expr2})"), + ConsoleFunction::AssertNeq(expr1, expr2) => write!(f, "assert_neq({expr1}, {expr2})"), } } } diff --git a/compiler/ast/src/statement/finalize.rs b/compiler/ast/src/statement/finalize.rs index 1d8bbb8d20..c915eff41a 100644 --- a/compiler/ast/src/statement/finalize.rs +++ b/compiler/ast/src/statement/finalize.rs @@ -34,7 +34,7 @@ impl fmt::Display for FinalizeStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "finalize(")?; for (i, param) in self.arguments.iter().enumerate() { - write!(f, "{}", param)?; + write!(f, "{param}")?; if i < self.arguments.len() - 1 { write!(f, ", ")?; } diff --git a/compiler/ast/src/statement/iteration.rs b/compiler/ast/src/statement/iteration.rs index 185dc0cf13..1a24ddab35 100644 --- a/compiler/ast/src/statement/iteration.rs +++ b/compiler/ast/src/statement/iteration.rs @@ -53,8 +53,8 @@ impl fmt::Display for IterationStatement { let eq = if self.inclusive { "=" } else { "" }; write!( f, - "for {} in {}..{}{} {}", - self.variable, self.start, eq, self.stop, self.block + "for {} in {}..{eq}{} {}", + self.variable, self.start, self.stop, self.block ) } } diff --git a/compiler/ast/src/struct/mod.rs b/compiler/ast/src/struct/mod.rs index 9abc3a75f2..3ddc8b208e 100644 --- a/compiler/ast/src/struct/mod.rs +++ b/compiler/ast/src/struct/mod.rs @@ -68,7 +68,7 @@ impl fmt::Display for Struct { f.write_str(if self.is_record { "record" } else { "struct" })?; writeln!(f, " {} {{ ", self.identifier)?; for field in self.members.iter() { - writeln!(f, " {}", field)?; + writeln!(f, " {field}")?; } write!(f, "}}") } diff --git a/compiler/ast/src/types/type_.rs b/compiler/ast/src/types/type_.rs index 62e2933dfa..ea1ba808cb 100644 --- a/compiler/ast/src/types/type_.rs +++ b/compiler/ast/src/types/type_.rs @@ -86,12 +86,12 @@ impl fmt::Display for Type { Type::Boolean => write!(f, "boolean"), Type::Field => write!(f, "field"), Type::Group => write!(f, "group"), - Type::Identifier(ref variable) => write!(f, "{}", variable), - Type::Integer(ref integer_type) => write!(f, "{}", integer_type), - Type::Mapping(ref mapping_type) => write!(f, "{}", mapping_type), + Type::Identifier(ref variable) => write!(f, "{variable}"), + Type::Integer(ref integer_type) => write!(f, "{integer_type}"), + Type::Mapping(ref mapping_type) => write!(f, "{mapping_type}"), Type::Scalar => write!(f, "scalar"), Type::String => write!(f, "string"), - Type::Tuple(ref tuple) => write!(f, "{}", tuple), + Type::Tuple(ref tuple) => write!(f, "{tuple}"), Type::Unit => write!(f, "()"), Type::Err => write!(f, "error"), } diff --git a/compiler/compiler/src/compiler.rs b/compiler/compiler/src/compiler.rs index 2b44523697..d2c0a30432 100644 --- a/compiler/compiler/src/compiler.rs +++ b/compiler/compiler/src/compiler.rs @@ -86,7 +86,7 @@ impl<'a> Compiler<'a> { hasher.update(unparsed_file.as_bytes()); let hash = hasher.finalize(); - Ok(format!("{:x}", hash)) + Ok(format!("{hash:x}")) } /// Parses and stores a program file content from a string, constructs a syntax tree, and generates a program. diff --git a/compiler/compiler/src/test.rs b/compiler/compiler/src/test.rs index c239fe5483..6b95ea9a45 100644 --- a/compiler/compiler/src/test.rs +++ b/compiler/compiler/src/test.rs @@ -81,7 +81,7 @@ fn hash_content(content: &str) -> String { hasher.update(content); let hash = hasher.finalize(); - format!("{:x}", hash) + format!("{hash:x}") } fn hash_file(path: &str) -> String { @@ -253,7 +253,7 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result Result::open(&directory).map_err(LeoError::Anyhow))?; diff --git a/compiler/parser/examples/input_parser.rs b/compiler/parser/examples/input_parser.rs index 7b52e7706c..815f9138f7 100644 --- a/compiler/parser/examples/input_parser.rs +++ b/compiler/parser/examples/input_parser.rs @@ -60,7 +60,7 @@ fn main() -> Result<(), String> { })?; if opt.print_stdout { - println!("{}", input_tree); + println!("{input_tree}"); } let out_path = if let Some(out_dir) = opt.out_dir_path { diff --git a/compiler/parser/examples/parser.rs b/compiler/parser/examples/parser.rs index 4eb8c7ef0d..bbe402432c 100644 --- a/compiler/parser/examples/parser.rs +++ b/compiler/parser/examples/parser.rs @@ -51,14 +51,14 @@ fn main() -> Result<(), String> { Handler::with(|h| { let ast = leo_parser::parse_ast(h, &code.src, code.start_pos)?; let json = Ast::to_json_string(&ast)?; - println!("{}", json); + println!("{json}"); Ok(json) }) .map_err(|b| b.to_string()) })?; if opt.print_stdout { - println!("{}", serialized_leo_tree); + println!("{serialized_leo_tree}"); } let out_path = if let Some(out_dir) = opt.out_dir_path { diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index 47d675b108..3364f485eb 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -195,7 +195,7 @@ impl<'a> ParserContext<'a> { if self.eat_any(tokens) { Ok(self.prev_token.span) } else { - self.unexpected(tokens.iter().map(|x| format!("'{}'", x)).collect::>().join(", ")) + self.unexpected(tokens.iter().map(|x| format!("'{x}'")).collect::>().join(", ")) } } diff --git a/compiler/parser/src/parser/expression.rs b/compiler/parser/src/parser/expression.rs index 9411f90426..64e95e68e4 100644 --- a/compiler/parser/src/parser/expression.rs +++ b/compiler/parser/src/parser/expression.rs @@ -263,7 +263,7 @@ impl ParserContext<'_> { Expression::Literal(Literal::Integer(integer_type, string, span)) if op == UnaryOperation::Negate && inner_is_integer => { - Expression::Literal(Literal::Integer(integer_type, format!("-{}", string), op_span + span)) + Expression::Literal(Literal::Integer(integer_type, format!("-{string}"), op_span + span)) } // Otherwise, produce a unary expression. _ => Expression::Unary(UnaryExpression { @@ -438,7 +438,7 @@ impl ParserContext<'_> { let (advanced, gc) = self.look_ahead(*dist, |t0| match &t0.token { Token::Add => Some((1, GroupCoordinate::SignHigh)), Token::Sub => self.look_ahead(*dist + 1, |t1| match &t1.token { - Token::Integer(value) => Some((2, GroupCoordinate::Number(format!("-{}", value), t1.span))), + Token::Integer(value) => Some((2, GroupCoordinate::Number(format!("-{value}"), t1.span))), _ => Some((1, GroupCoordinate::SignLow)), }), Token::Underscore => Some((1, GroupCoordinate::Inferred)), diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 9468777e76..06ba5a5c9d 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -68,7 +68,7 @@ impl ParserContext<'_> { &token.token, expected .iter() - .map(|x| format!("'{}'", x)) + .map(|x| format!("'{x}'")) .collect::>() .join(", "), token.span, diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index fbe791aee3..a80752d80f 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -156,7 +156,7 @@ mod tests { let tokens = tokenize(&sf.src, sf.start_pos).unwrap(); let mut output = String::new(); for SpannedToken { token, .. } in tokens.iter() { - write!(output, "{} ", token).expect("failed to write string"); + write!(output, "{token} ").expect("failed to write string"); } assert_eq!( diff --git a/compiler/parser/src/tokenizer/token.rs b/compiler/parser/src/tokenizer/token.rs index 3d1bf56d47..54a086d264 100644 --- a/compiler/parser/src/tokenizer/token.rs +++ b/compiler/parser/src/tokenizer/token.rs @@ -249,14 +249,14 @@ impl fmt::Display for Token { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use Token::*; match self { - CommentLine(s) => write!(f, "{}", s), - CommentBlock(s) => write!(f, "{}", s), - StaticString(s) => write!(f, "\"{}\"", s), - Identifier(s) => write!(f, "{}", s), - Integer(s) => write!(f, "{}", s), + CommentLine(s) => write!(f, "{s}"), + CommentBlock(s) => write!(f, "{s}"), + StaticString(s) => write!(f, "\"{s}\""), + Identifier(s) => write!(f, "{s}"), + Integer(s) => write!(f, "{s}"), True => write!(f, "true"), False => write!(f, "false"), - AddressLit(s) => write!(f, "{}", s), + AddressLit(s) => write!(f, "{s}"), WhiteSpace => write!(f, "whitespace"), Not => write!(f, "!"), diff --git a/compiler/passes/src/code_generation/visit_expressions.rs b/compiler/passes/src/code_generation/visit_expressions.rs index 8adb807f49..4b5ee1fb5d 100644 --- a/compiler/passes/src/code_generation/visit_expressions.rs +++ b/compiler/passes/src/code_generation/visit_expressions.rs @@ -53,7 +53,7 @@ impl<'a> CodeGenerator<'a> { } fn visit_value(&mut self, input: &'a Literal) -> (String, String) { - (format!("{}", input), String::new()) + (format!("{input}"), String::new()) } fn visit_binary(&mut self, input: &'a BinaryExpression) -> (String, String) { @@ -125,7 +125,7 @@ impl<'a> CodeGenerator<'a> { }; let destination_register = format!("r{}", self.next_register); - let unary_instruction = format!(" {} {} into {};\n", opcode, expression_operand, destination_register); + let unary_instruction = format!(" {opcode} {expression_operand} into {destination_register};\n"); // Increment the register counter. self.next_register += 1; @@ -165,7 +165,7 @@ impl<'a> CodeGenerator<'a> { let name = if let Some((is_record, type_)) = self.composite_mapping.get(&input.name.name) { if *is_record { // record.private; - format!("{}.{}", input.name, type_) + format!("{}.{type_}", input.name) } else { // foo; // no visibility for interfaces input.name.to_string() @@ -195,7 +195,7 @@ impl<'a> CodeGenerator<'a> { }; // Push operand name to struct init instruction. - write!(struct_init_instruction, "{} ", operand).expect("failed to write to string"); + write!(struct_init_instruction, "{operand} ").expect("failed to write to string"); } // Push destination register to struct init instruction. @@ -218,7 +218,7 @@ impl<'a> CodeGenerator<'a> { fn visit_member_access(&mut self, input: &'a MemberAccess) -> (String, String) { let (inner_struct, _inner_instructions) = self.visit_expression(&input.inner); - let member_access_instruction = format!("{}.{}", inner_struct, input.name); + let member_access_instruction = format!("{inner_struct}.{}", input.name); (member_access_instruction, String::new()) } @@ -244,19 +244,19 @@ impl<'a> CodeGenerator<'a> { }; // Construct associated function call. - let mut associated_function_call = format!(" {}.{} ", input.name, symbol); + let mut associated_function_call = format!(" {}.{symbol} ", input.name); let mut instructions = String::new(); // Visit each function argument and accumulate instructions from expressions. for arg in input.args.iter() { let (arg_string, arg_instructions) = self.visit_expression(arg); - write!(associated_function_call, "{} ", arg_string).expect("failed to write associated function argument"); + write!(associated_function_call, "{arg_string} ").expect("failed to write associated function argument"); instructions.push_str(&arg_instructions); } // Push destination register to associated function call instruction. let destination_register = format!("r{}", self.next_register); - writeln!(associated_function_call, "into {};", destination_register) + writeln!(associated_function_call, "into {destination_register};") .expect("failed to write dest register for associated function"); instructions.push_str(&associated_function_call); @@ -277,20 +277,20 @@ impl<'a> CodeGenerator<'a> { fn visit_call(&mut self, input: &'a CallExpression) -> (String, String) { let mut call_instruction = match &input.external { - Some(external) => format!(" call {}.aleo/{} ", external, input.function), + Some(external) => format!(" call {external}.aleo/{} ", input.function), None => format!(" call {} ", input.function), }; let mut instructions = String::new(); for argument in input.arguments.iter() { let (argument, argument_instructions) = self.visit_expression(argument); - write!(call_instruction, "{} ", argument).expect("failed to write to string"); + write!(call_instruction, "{argument} ").expect("failed to write to string"); instructions.push_str(&argument_instructions); } // Push destination register to call instruction. let destination_register = format!("r{}", self.next_register); - writeln!(call_instruction, "into {};", destination_register).expect("failed to write to string"); + writeln!(call_instruction, "into {destination_register};").expect("failed to write to string"); instructions.push_str(&call_instruction); // Increment the register counter. diff --git a/compiler/passes/src/code_generation/visit_program.rs b/compiler/passes/src/code_generation/visit_program.rs index 0e4bd1c632..b391a79530 100644 --- a/compiler/passes/src/code_generation/visit_program.rs +++ b/compiler/passes/src/code_generation/visit_program.rs @@ -110,7 +110,7 @@ impl<'a> CodeGenerator<'a> { // todo: We do not need the import program string because we generate instructions for imports separately during leo build. // Generate string for import statement. - format!("import {}.aleo;", import_name) + format!("import {import_name}.aleo;") } fn visit_struct_or_record(&mut self, struct_: &'a Struct) -> String { @@ -193,7 +193,7 @@ impl<'a> CodeGenerator<'a> { } }; - writeln!(function_string, " input {} as {};", register_string, type_string,) + writeln!(function_string, " input {register_string} as {type_string};",) .expect("failed to write to string"); } @@ -238,7 +238,7 @@ impl<'a> CodeGenerator<'a> { } }; - writeln!(function_string, " input {} as {};", register_string, type_string,) + writeln!(function_string, " input {register_string} as {type_string};",) .expect("failed to write to string"); } @@ -265,12 +265,12 @@ impl<'a> CodeGenerator<'a> { let (is_record, _) = self.composite_mapping.get(&identifier.name).unwrap(); match is_record { // If the type is a record, then declare the type as is. - true => format!("{}.record", identifier), + true => format!("{identifier}.record"), // If the type is a struct, then add the public modifier. - false => format!("{}.public", identifier), + false => format!("{identifier}.public"), } } - type_ => format!("{}.public", type_), + type_ => format!("{type_}.public"), } }; diff --git a/compiler/passes/src/code_generation/visit_statements.rs b/compiler/passes/src/code_generation/visit_statements.rs index 3c4f44a7e0..783d22384f 100644 --- a/compiler/passes/src/code_generation/visit_statements.rs +++ b/compiler/passes/src/code_generation/visit_statements.rs @@ -116,7 +116,7 @@ impl<'a> CodeGenerator<'a> { let (index, mut instructions) = self.visit_expression(&input.index); let (amount, amount_instructions) = self.visit_expression(&input.amount); instructions.push_str(&amount_instructions); - instructions.push_str(&format!(" increment {}[{}] by {};\n", input.mapping, index, amount)); + instructions.push_str(&format!(" increment {}[{index}] by {amount};\n", input.mapping)); instructions } @@ -125,7 +125,7 @@ impl<'a> CodeGenerator<'a> { let (index, mut instructions) = self.visit_expression(&input.index); let (amount, amount_instructions) = self.visit_expression(&input.amount); instructions.push_str(&amount_instructions); - instructions.push_str(&format!(" decrement {}[{}] by {};\n", input.mapping, index, amount)); + instructions.push_str(&format!(" decrement {}[{index}] by {amount};\n", input.mapping)); instructions } @@ -136,7 +136,7 @@ impl<'a> CodeGenerator<'a> { for argument in input.arguments.iter() { let (argument, argument_instructions) = self.visit_expression(argument); - write!(finalize_instruction, " {}", argument).expect("failed to write to string"); + write!(finalize_instruction, " {argument}").expect("failed to write to string"); instructions.push_str(&argument_instructions); } writeln!(finalize_instruction, ";").expect("failed to write to string"); @@ -171,7 +171,7 @@ impl<'a> CodeGenerator<'a> { let mut generate_assert_instruction = |name: &str, left: &'a Expression, right: &'a Expression| { let (left_operand, left_instructions) = self.visit_expression(left); let (right_operand, right_instructions) = self.visit_expression(right); - let assert_instruction = format!(" {} {} {};\n", name, left_operand, right_operand); + let assert_instruction = format!(" {name} {left_operand} {right_operand};\n"); // Concatenate the instructions. let mut instructions = left_instructions; @@ -183,7 +183,7 @@ impl<'a> CodeGenerator<'a> { match &input.function { ConsoleFunction::Assert(expr) => { let (operand, mut instructions) = self.visit_expression(expr); - let assert_instruction = format!(" assert.eq {} true;\n", operand); + let assert_instruction = format!(" assert.eq {operand} true;\n"); instructions.push_str(&assert_instruction); instructions diff --git a/compiler/passes/src/code_generation/visit_type.rs b/compiler/passes/src/code_generation/visit_type.rs index a8ed2a7ec3..9c4e04ed52 100644 --- a/compiler/passes/src/code_generation/visit_type.rs +++ b/compiler/passes/src/code_generation/visit_type.rs @@ -27,8 +27,8 @@ impl<'a> CodeGenerator<'a> { | Type::Group | Type::Scalar | Type::String - | Type::Integer(..) => format!("{}", input), - Type::Identifier(ident) => format!("{}", ident), + | Type::Integer(..) => format!("{input}"), + Type::Identifier(ident) => format!("{ident}"), Type::Mapping(_) => { unreachable!("Mapping types are not supported at this phase of compilation") } @@ -45,11 +45,11 @@ impl<'a> CodeGenerator<'a> { // When the type is a record. // Note that this unwrap is safe because all composite types have been added to the mapping. Type::Identifier(identifier) if self.composite_mapping.get(&identifier.name).unwrap().0 => { - format!("{}.record", identifier) + format!("{identifier}.record") } _ => match visibility { Mode::None => self.visit_type(type_), - _ => format!("{}.{}", self.visit_type(type_), visibility), + _ => format!("{}.{visibility}", self.visit_type(type_)), }, } } diff --git a/compiler/passes/src/static_single_assignment/assigner.rs b/compiler/passes/src/static_single_assignment/assigner.rs index 7ef7520411..655ee5d5f8 100644 --- a/compiler/passes/src/static_single_assignment/assigner.rs +++ b/compiler/passes/src/static_single_assignment/assigner.rs @@ -29,7 +29,7 @@ impl Assigner { /// Return a new unique `Symbol` from a `&str`. pub(crate) fn unique_symbol(&mut self, arg: impl Display) -> Symbol { self.counter += 1; - Symbol::intern(&format!("{}${}", arg, self.counter - 1)) + Symbol::intern(&format!("{arg}${}", self.counter - 1)) } /// Constructs the assignment statement `place = expr;`. diff --git a/compiler/passes/src/static_single_assignment/rename_statement.rs b/compiler/passes/src/static_single_assignment/rename_statement.rs index 9faf7010d2..abce1b8cff 100644 --- a/compiler/passes/src/static_single_assignment/rename_statement.rs +++ b/compiler/passes/src/static_single_assignment/rename_statement.rs @@ -119,7 +119,7 @@ impl StatementConsumer for StaticSingleAssigner<'_> { let create_phi_argument = |table: &RenameTable, symbol: Symbol| { let name = *table .lookup(symbol) - .unwrap_or_else(|| panic!("Symbol {} should exist in the program.", symbol)); + .unwrap_or_else(|| panic!("Symbol {symbol} should exist in the program.")); Box::new(Expression::Identifier(Identifier { name, span: Default::default(), diff --git a/compiler/passes/src/type_checking/checker.rs b/compiler/passes/src/type_checking/checker.rs index c8fdd85559..ba5adaefdd 100644 --- a/compiler/passes/src/type_checking/checker.rs +++ b/compiler/passes/src/type_checking/checker.rs @@ -247,7 +247,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_bool_int_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| BOOLEAN_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{}, {}", BOOLEAN_TYPE, types_to_string(&INT_TYPES)), + format!("{BOOLEAN_TYPE}, {}", types_to_string(&INT_TYPES)), type_, span, ) @@ -257,7 +257,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_field_int_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| FIELD_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{}, {}", FIELD_TYPE, types_to_string(&INT_TYPES)), + format!("{FIELD_TYPE}, {}", types_to_string(&INT_TYPES)), type_, span, ) @@ -267,7 +267,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_field_group_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_), - format!("{}, {}", FIELD_TYPE, GROUP_TYPE), + format!("{FIELD_TYPE}, {GROUP_TYPE}"), type_, span, ) @@ -277,7 +277,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_field_group_int_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{}, {}, {}", FIELD_TYPE, GROUP_TYPE, types_to_string(&INT_TYPES),), + format!("{FIELD_TYPE}, {GROUP_TYPE}, {}", types_to_string(&INT_TYPES),), type_, span, ) @@ -287,7 +287,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_field_group_signed_int_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_) | SIGNED_INT_TYPES.contains(type_), - format!("{}, {}, {}", FIELD_TYPE, GROUP_TYPE, types_to_string(&SIGNED_INT_TYPES),), + format!("{FIELD_TYPE}, {GROUP_TYPE}, {}", types_to_string(&SIGNED_INT_TYPES),), type_, span, ) @@ -297,7 +297,7 @@ impl<'a> TypeChecker<'a> { pub(crate) fn assert_field_scalar_int_type(&self, type_: &Option, span: Span) { self.check_type( |type_: &Type| FIELD_TYPE.eq(type_) | SCALAR_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{}, {}, {}", FIELD_TYPE, SCALAR_TYPE, types_to_string(&INT_TYPES),), + format!("{FIELD_TYPE}, {SCALAR_TYPE}, {}", types_to_string(&INT_TYPES),), type_, span, ) diff --git a/docs/grammar/src/main.rs b/docs/grammar/src/main.rs index 2ff1f0cac8..b86ab3bf45 100644 --- a/docs/grammar/src/main.rs +++ b/docs/grammar/src/main.rs @@ -162,14 +162,14 @@ impl<'a> Processor<'a> { .into_iter() .collect::>() .into_iter() - .map(|tag| format!("[{}](#user-content-{})", &tag, tag)) + .map(|tag| format!("[{}](#user-content-{tag})", &tag)) .collect::>(); keyvec.sort(); let keys = keyvec.join(", "); self.append_str("```"); if !keys.is_empty() { - self.append_str(&format!("\nGo to: _{}_;\n", keys)); + self.append_str(&format!("\nGo to: _{keys}_;\n")); } } (_, _) => (), diff --git a/errors/src/common/backtraced.rs b/errors/src/common/backtraced.rs index c2f17c4ece..ffdc2a8933 100644 --- a/errors/src/common/backtraced.rs +++ b/errors/src/common/backtraced.rs @@ -128,7 +128,7 @@ impl fmt::Display for Backtraced { write!(f, "{}", message.bold().yellow())?; } } else { - write!(f, "{}", message)?; + write!(f, "{message}")?; }; if let Some(help) = &self.help { @@ -149,7 +149,7 @@ impl fmt::Display for Backtraced { let trace = printer .format_trace_to_string(&self.backtrace) .map_err(|_| fmt::Error)?; - write!(f, "{}", trace)?; + write!(f, "{trace}")?; } "full" => { let mut printer = BacktracePrinter::default(); @@ -157,7 +157,7 @@ impl fmt::Display for Backtraced { let trace = printer .format_trace_to_string(&self.backtrace) .map_err(|_| fmt::Error)?; - write!(f, "{}", trace)?; + write!(f, "{trace}")?; } _ => {} } diff --git a/errors/src/common/formatted.rs b/errors/src/common/formatted.rs index f8bc20ec64..1aa11e26fa 100644 --- a/errors/src/common/formatted.rs +++ b/errors/src/common/formatted.rs @@ -141,7 +141,7 @@ impl fmt::Display for Formatted { write!(f, "{}", message.bold().yellow())?; } } else { - write!(f, "{}", message)?; + write!(f, "{message}")?; }; write!( @@ -190,7 +190,7 @@ impl fmt::Display for Formatted { let trace = printer .format_trace_to_string(&self.backtrace.backtrace) .map_err(|_| fmt::Error)?; - write!(f, "\n{}", trace)?; + write!(f, "\n{trace}")?; } "full" => { let mut printer = BacktracePrinter::default(); @@ -199,7 +199,7 @@ impl fmt::Display for Formatted { let trace = printer .format_trace_to_string(&self.backtrace.backtrace) .map_err(|_| fmt::Error)?; - write!(f, "\n{}", trace)?; + write!(f, "\n{trace}")?; } _ => {} } diff --git a/errors/src/emitter/mod.rs b/errors/src/emitter/mod.rs index f9b118aac9..c3e3026757 100644 --- a/errors/src/emitter/mod.rs +++ b/errors/src/emitter/mod.rs @@ -43,7 +43,7 @@ pub struct StderrEmitter { impl Emitter for StderrEmitter { fn emit_err(&mut self, err: LeoError) { self.last_error_code = Some(err.exit_code()); - eprintln!("{}", err); + eprintln!("{err}"); } fn last_emitted_err_code(&self) -> Option { @@ -89,7 +89,7 @@ impl fmt::Display for Buffer { x.fmt(f)?; } for x in iter { - f.write_fmt(format_args!("\n{}", x))?; + f.write_fmt(format_args!("\n{x}"))?; } Ok(()) } diff --git a/errors/src/errors/ast/ast_errors.rs b/errors/src/errors/ast/ast_errors.rs index 8a75facdf7..985d55af3f 100644 --- a/errors/src/errors/ast/ast_errors.rs +++ b/errors/src/errors/ast/ast_errors.rs @@ -30,7 +30,7 @@ create_messages!( @backtraced failed_to_convert_ast_to_json_string { args: (error: impl ErrorArg), - msg: format!("failed to convert ast to a json string {}", error), + msg: format!("failed to convert ast to a json string {error}"), help: None, } @@ -38,7 +38,7 @@ create_messages!( @backtraced failed_to_create_ast_json_file { args: (path: impl Debug, error: impl ErrorArg), - msg: format!("failed to create ast json file `{:?}` {}", path, error), + msg: format!("failed to create ast json file `{path:?}` {error}"), help: None, } @@ -46,7 +46,7 @@ create_messages!( @backtraced failed_to_write_ast_to_json_file { args: (path: impl Debug, error: impl ErrorArg), - msg: format!("failed to write ast to a json file `{:?}` {}", path, error), + msg: format!("failed to write ast to a json file `{path:?}` {error}"), help: None, } @@ -54,7 +54,7 @@ create_messages!( @backtraced failed_to_read_json_string_to_ast { args: (error: impl ErrorArg), - msg: format!("failed to convert json string to an ast {}", error), + msg: format!("failed to convert json string to an ast {error}"), help: None, } @@ -62,7 +62,7 @@ create_messages!( @backtraced failed_to_read_json_file { args: (path: impl Debug, error: impl ErrorArg), - msg: format!("failed to convert json file `{:?}` to an ast {}", path, error), + msg: format!("failed to convert json file `{path:?}` to an ast {error}"), help: None, } @@ -70,7 +70,7 @@ create_messages!( @backtraced failed_to_convert_ast_to_json_value { args: (error: impl ErrorArg), - msg: format!("failed to convert ast to a json value {}", error), + msg: format!("failed to convert ast to a json value {error}"), help: None, } diff --git a/errors/src/errors/cli/cli_errors.rs b/errors/src/errors/cli/cli_errors.rs index 6ce16a05f2..c2c166c291 100644 --- a/errors/src/errors/cli/cli_errors.rs +++ b/errors/src/errors/cli/cli_errors.rs @@ -30,7 +30,7 @@ create_messages!( @backtraced cli_io_error { args: (error: impl ErrorArg), - msg: format!("cli io error {}", error), + msg: format!("cli io error {error}"), help: None, } @@ -38,7 +38,7 @@ create_messages!( @backtraced could_not_fetch_versions { args: (error: impl ErrorArg), - msg: format!("Could not fetch versions: {}", error), + msg: format!("Could not fetch versions: {error}"), help: None, } @@ -54,7 +54,7 @@ create_messages!( @backtraced self_update_error { args: (error: impl ErrorArg), - msg: format!("self update crate Error: {}", error), + msg: format!("self update crate Error: {error}"), help: None, } @@ -62,7 +62,7 @@ create_messages!( @backtraced self_update_build_error { args: (error: impl ErrorArg), - msg: format!("self update crate failed to build Error: {}", error), + msg: format!("self update crate failed to build Error: {error}"), help: None, } @@ -70,14 +70,14 @@ create_messages!( @backtraced old_release_version { args: (current: impl Display, latest: impl Display), - msg: format!("Old release version {} {}", current, latest), + msg: format!("Old release version {current} {latest}"), help: None, } @backtraced failed_to_load_instructions { args: (error: impl Display), - msg: format!("Failed to load compiled Aleo instructions into an Aleo file.\nSnarkVM Error: {}", error), + msg: format!("Failed to load compiled Aleo instructions into an Aleo file.\nSnarkVM Error: {error}"), help: Some("Generated Aleo instructions have been left in `main.aleo`".to_string()), } @@ -91,63 +91,63 @@ create_messages!( @backtraced failed_to_execute_aleo_build { args: (error: impl Display), - msg: format!("Failed to execute the `aleo build` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to execute the `aleo build` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_execute_aleo_new { args: (error: impl Display), - msg: format!("Failed to execute the `aleo new` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to execute the `aleo new` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_execute_aleo_run { args: (error: impl Display), - msg: format!("Failed to execute the `aleo run` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to execute the `aleo run` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_execute_aleo_node { args: (error: impl Display), - msg: format!("Failed to execute the `aleo node` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to execute the `aleo node` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_execute_aleo_deploy { args: (error: impl Display), - msg: format!("Failed to execute the `aleo deploy` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to execute the `aleo deploy` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_parse_aleo_new { args: (error: impl Display), - msg: format!("Failed to parse the `aleo new` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to parse the `aleo new` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_parse_aleo_run { args: (error: impl Display), - msg: format!("Failed to parse the `aleo run` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to parse the `aleo run` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_parse_aleo_node { args: (error: impl Display), - msg: format!("Failed to parse the `aleo node` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to parse the `aleo node` command.\nSnarkVM Error: {error}"), help: None, } @backtraced failed_to_parse_aleo_deploy { args: (error: impl Display), - msg: format!("Failed to parse the `aleo deploy` command.\nSnarkVM Error: {}", error), + msg: format!("Failed to parse the `aleo deploy` command.\nSnarkVM Error: {error}"), help: None, } ); diff --git a/errors/src/errors/compiler/compiler_errors.rs b/errors/src/errors/compiler/compiler_errors.rs index 77535cc413..83d80daa2a 100644 --- a/errors/src/errors/compiler/compiler_errors.rs +++ b/errors/src/errors/compiler/compiler_errors.rs @@ -31,7 +31,7 @@ create_messages!( @backtraced file_read_error { args: (path: impl Debug, error: impl ErrorArg), - msg: format!("Cannot read from the provided file path '{:?}': {}", path, error), + msg: format!("Cannot read from the provided file path '{path:?}': {error}"), help: None, } diff --git a/errors/src/errors/input/input_errors.rs b/errors/src/errors/input/input_errors.rs index 57a3b9713f..065789703b 100644 --- a/errors/src/errors/input/input_errors.rs +++ b/errors/src/errors/input/input_errors.rs @@ -28,9 +28,7 @@ create_messages!( unexpected_type { args: (expected: impl Display, received: impl Display), msg: format!( - "unexpected type, expected: '{}', received: '{}'", - expected, - received, + "unexpected type, expected: '{expected}', received: '{received}'", ), help: None, } @@ -39,7 +37,7 @@ create_messages!( @formatted illegal_expression { args: (expr: impl Display), - msg: format!("expression '{}' is not allowed in inputs", expr), + msg: format!("expression '{expr}' is not allowed in inputs"), help: None, } @@ -48,13 +46,12 @@ create_messages!( unexpected_section { args: (expected: &[impl Display], received: impl Display), msg: format!( - "unexpected section: expected {} -- got '{}'", + "unexpected section: expected {} -- got '{received}'", expected .iter() - .map(|x| format!("'{}'", x)) + .map(|x| format!("'{x}'")) .collect::>() - .join(", "), - received + .join(", ") ), help: None, } diff --git a/errors/src/errors/package/package_errors.rs b/errors/src/errors/package/package_errors.rs index 5306589a81..062eba1d23 100644 --- a/errors/src/errors/package/package_errors.rs +++ b/errors/src/errors/package/package_errors.rs @@ -31,7 +31,7 @@ create_messages!( @backtraced failed_to_get_input_file_entry { args: (error: impl ErrorArg), - msg: format!("failed to get input file entry: {}", error), + msg: format!("failed to get input file entry: {error}"), help: None, } @@ -39,7 +39,7 @@ create_messages!( @backtraced failed_to_get_input_file_type { args: (file: impl Debug, error: impl ErrorArg), - msg: format!("failed to get input file `{:?}` type: {}", file, error), + msg: format!("failed to get input file `{file:?}` type: {error}"), help: None, } @@ -47,7 +47,7 @@ create_messages!( @backtraced invalid_input_file_type { args: (file: impl Debug, type_: std::fs::FileType), - msg: format!("input file `{:?}` has invalid type: {:?}", file, type_), + msg: format!("input file `{file:?}` has invalid type: {type_:?}"), help: None, } @@ -55,7 +55,7 @@ create_messages!( @backtraced failed_to_create_inputs_directory { args: (error: impl ErrorArg), - msg: format!("failed creating inputs directory {}", error), + msg: format!("failed creating inputs directory {error}"), help: None, } @@ -63,7 +63,7 @@ create_messages!( @backtraced failed_to_read_circuit_file { args: (path: impl Debug), - msg: format!("Cannot read struct file from the provided file path - {:?}", path), + msg: format!("Cannot read struct file from the provided file path - {path:?}"), help: None, } @@ -71,7 +71,7 @@ create_messages!( @backtraced failed_to_read_inputs_directory { args: (error: impl ErrorArg), - msg: format!("failed reading inputs directory {}", error), + msg: format!("failed reading inputs directory {error}"), help: None, } @@ -79,7 +79,7 @@ create_messages!( @backtraced failed_to_read_input_file { args: (path: impl Debug), - msg: format!("Cannot read input file from the provided file path - {:?}", path), + msg: format!("Cannot read input file from the provided file path - {path:?}"), help: None, } @@ -87,7 +87,7 @@ create_messages!( @backtraced failed_to_read_snapshot_file { args: (path: impl Debug), - msg: format!("Cannot read snapshot file from the provided file path - {:?}", path), + msg: format!("Cannot read snapshot file from the provided file path - {path:?}"), help: None, } @@ -95,7 +95,7 @@ create_messages!( @backtraced failed_to_read_checksum_file { args: (path: impl Debug), - msg: format!("Cannot read checksum file from the provided file path - {:?}", path), + msg: format!("Cannot read checksum file from the provided file path - {path:?}"), help: None, } @@ -103,7 +103,7 @@ create_messages!( @backtraced io_error_circuit_file { args: (error: impl ErrorArg), - msg: format!("IO error struct file from the provided file path - {}", error), + msg: format!("IO error struct file from the provided file path - {error}"), help: None, } @@ -111,7 +111,7 @@ create_messages!( @backtraced io_error_checksum_file { args: (error: impl ErrorArg), - msg: format!("IO error checksum file from the provided file path - {}", error), + msg: format!("IO error checksum file from the provided file path - {error}"), help: None, } @@ -119,7 +119,7 @@ create_messages!( @backtraced io_error_main_file { args: (error: impl ErrorArg), - msg: format!("IO error main file from the provided file path - {}", error), + msg: format!("IO error main file from the provided file path - {error}"), help: None, } @@ -127,7 +127,7 @@ create_messages!( @backtraced failed_to_remove_circuit_file { args: (path: impl Debug), - msg: format!("failed removing struct file from the provided file path - {:?}", path), + msg: format!("failed removing struct file from the provided file path - {path:?}"), help: None, } @@ -135,7 +135,7 @@ create_messages!( @backtraced failed_to_remove_checksum_file { args: (path: impl Debug), - msg: format!("failed removing checksum file from the provided file path - {:?}", path), + msg: format!("failed removing checksum file from the provided file path - {path:?}"), help: None, } @@ -143,7 +143,7 @@ create_messages!( @backtraced failed_to_remove_snapshot_file { args: (path: impl Debug), - msg: format!("failed removing snapshot file from the provided file path - {:?}", path), + msg: format!("failed removing snapshot file from the provided file path - {path:?}"), help: None, } @@ -151,7 +151,7 @@ create_messages!( @backtraced io_error_input_file { args: (error: impl ErrorArg), - msg: format!("IO error input file from the provided file path - {}", error), + msg: format!("IO error input file from the provided file path - {error}"), help: None, } @@ -159,7 +159,7 @@ create_messages!( @backtraced io_error_gitignore_file { args: (error: impl ErrorArg), - msg: format!("IO error gitignore file from the provided file path - {}", error), + msg: format!("IO error gitignore file from the provided file path - {error}"), help: None, } @@ -167,7 +167,7 @@ create_messages!( @backtraced failed_to_create_source_directory { args: (error: impl ErrorArg), - msg: format!("Failed creating source directory {}.", error), + msg: format!("Failed creating source directory {error}."), help: None, } @@ -175,7 +175,7 @@ create_messages!( @backtraced failed_to_get_leo_file_entry { args: (error: impl ErrorArg), - msg: format!("Failed to get Leo file entry: {}.", error), + msg: format!("Failed to get Leo file entry: {error}."), help: None, } @@ -183,7 +183,7 @@ create_messages!( @backtraced failed_to_get_leo_file_extension { args: (extension: impl Debug), - msg: format!("Failed to get Leo file extension: {:?}.", extension), + msg: format!("Failed to get Leo file extension: {extension:?}."), help: None, } @@ -191,7 +191,7 @@ create_messages!( @backtraced invalid_leo_file_extension { args: (file: impl Debug, extension: impl Debug), - msg: format!("Source file `{:?}` has invalid extension: {:?}.", file, extension), + msg: format!("Source file `{file:?}` has invalid extension: {extension:?}."), help: None, } @@ -199,7 +199,7 @@ create_messages!( @backtraced failed_to_initialize_package { args: (package: impl Display, path: impl Debug), - msg: format!("failed to initialize package {} {:?}", package, path), + msg: format!("failed to initialize package {package} {path:?}"), help: None, } @@ -207,7 +207,7 @@ create_messages!( @backtraced invalid_package_name { args: (package: impl Display), - msg: format!("invalid project name {}", package), + msg: format!("invalid project name {package}"), help: None, } @@ -215,7 +215,7 @@ create_messages!( @backtraced directory_not_found { args: (dirname: impl Display, path: impl Display), - msg: format!("The `{}` does not exist at `{}`.", dirname, path), + msg: format!("The `{dirname}` does not exist at `{path}`."), help: None, } @@ -223,7 +223,7 @@ create_messages!( @backtraced failed_to_create_directory { args: (dirname: impl Display, error: impl ErrorArg), - msg: format!("failed to create directory `{}`, error: {}.", dirname, error), + msg: format!("failed to create directory `{dirname}`, error: {error}."), help: None, } @@ -231,7 +231,7 @@ create_messages!( @backtraced failed_to_remove_directory { args: (dirname: impl Display, error: impl ErrorArg), - msg: format!("failed to remove directory: {}, error: {}", dirname, error), + msg: format!("failed to remove directory: {dirname}, error: {error}"), help: None, } @@ -239,7 +239,7 @@ create_messages!( @backtraced failed_to_read_file { args: (path: impl Display, error: impl ErrorArg), - msg: format!("failed to read file: {}, error: {}", path, error), + msg: format!("failed to read file: {path}, error: {error}"), help: None, } @@ -253,42 +253,42 @@ create_messages!( @backtraced failed_to_set_cwd { args: (dir: impl Display, error: impl ErrorArg), - msg: format!("Failed to set current working directory to `{}`. Error: {}.", dir, error), + msg: format!("Failed to set current working directory to `{dir}`. Error: {error}."), help: None, } @backtraced failed_to_open_manifest { args: (error: impl Display), - msg: format!("Failed to open manifest file: {}", error), + msg: format!("Failed to open manifest file: {error}"), help: Some("Create a package by running `leo new`.".to_string()), } @backtraced failed_to_open_aleo_file { args: (error: impl Display), - msg: format!("Failed to open Aleo file: {}", error), + msg: format!("Failed to open Aleo file: {error}"), help: Some("Create a package by running `leo new`.".to_string()), } @backtraced failed_to_create_aleo_file { args: (error: impl Display), - msg: format!("Failed to create Aleo file: {}.", error), + msg: format!("Failed to create Aleo file: {error}."), help: None, } @backtraced failed_to_write_aleo_file { args: (error: impl Display), - msg: format!("Failed to write aleo file: {}.", error), + msg: format!("Failed to write aleo file: {error}."), help: None, } @backtraced failed_to_remove_aleo_file { args: (error: impl Display), - msg: format!("Failed to remove aleo file: {}.", error), + msg: format!("Failed to remove aleo file: {error}."), help: None, } diff --git a/errors/src/errors/parser/parser_errors.rs b/errors/src/errors/parser/parser_errors.rs index 45b0a13192..b36ab53d6a 100644 --- a/errors/src/errors/parser/parser_errors.rs +++ b/errors/src/errors/parser/parser_errors.rs @@ -36,7 +36,7 @@ create_messages!( @formatted invalid_address_lit { args: (token: impl Display), - msg: format!("invalid address literal: '{}'", token), + msg: format!("invalid address literal: '{token}'"), help: None, } @@ -60,7 +60,7 @@ create_messages!( @formatted unexpected_whitespace { args: (left: impl Display, right: impl Display), - msg: format!("Unexpected white space between terms {} and {}", left, right), + msg: format!("Unexpected white space between terms {left} and {right}"), help: None, } @@ -68,7 +68,7 @@ create_messages!( @formatted unexpected { args: (found: impl Display, expected: impl Display), - msg: format!("expected {} -- found '{}'", expected, found), + msg: format!("expected {expected} -- found '{found}'"), help: None, } @@ -85,13 +85,12 @@ create_messages!( unexpected_ident { args: (found: impl Display, expected: &[impl Display]), msg: format!( - "unexpected identifier: expected {} -- found '{}'", + "unexpected identifier: expected {} -- found '{found}'", expected .iter() - .map(|x| format!("'{}'", x)) + .map(|x| format!("'{x}'")) .collect::>() .join(", "), - found ), help: None, } @@ -100,7 +99,7 @@ create_messages!( @formatted unexpected_statement { args: (found: impl Display, expected: impl Display), - msg: format!("unexpected statement: expected '{}', found '{}'", expected, found), + msg: format!("unexpected statement: expected '{expected}', found '{found}'"), help: None, } @@ -108,7 +107,7 @@ create_messages!( @formatted unexpected_str { args: (found: impl Display, expected: impl Display), - msg: format!("unexpected string: expected '{}', found '{}'", expected, found), + msg: format!("unexpected string: expected '{expected}', found '{found}'"), help: None, } @@ -132,7 +131,7 @@ create_messages!( @backtraced lexer_expected_valid_escaped_char { args: (input: impl Display), - msg: format!("Expected a valid escape character but found `{}`.", input), + msg: format!("Expected a valid escape character but found `{input}`."), help: None, } @@ -140,7 +139,7 @@ create_messages!( @backtraced lexer_string_not_closed { args: (input: impl Display), - msg: format!("Expected a closed string but found `{}`.", input), + msg: format!("Expected a closed string but found `{input}`."), help: None, } @@ -156,7 +155,7 @@ create_messages!( @backtraced lexer_block_comment_does_not_close_before_eof { args: (input: impl Display), - msg: format!("Block comment does not close with content: `{}`.", input), + msg: format!("Block comment does not close with content: `{input}`."), help: None, } @@ -164,7 +163,7 @@ create_messages!( @backtraced could_not_lex { args: (input: impl Display), - msg: format!("Could not lex the following content: `{}`.\n", input), + msg: format!("Could not lex the following content: `{input}`.\n"), help: None, } @@ -172,7 +171,7 @@ create_messages!( @formatted implicit_values_not_allowed { args: (input: impl Display), - msg: format!("Could not parse the implicit value: {}.", input), + msg: format!("Could not parse the implicit value: {input}."), help: None, } @@ -180,7 +179,7 @@ create_messages!( @backtraced lexer_hex_number_provided { args: (input: impl Display), - msg: format!("A hex number `{}..` was provided but hex is not allowed.", input), + msg: format!("A hex number `{input}..` was provided but hex is not allowed."), help: None, } diff --git a/leo/commands/build.rs b/leo/commands/build.rs index ab254ff680..394be25ee3 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -230,7 +230,7 @@ fn compile_leo_file( // Create the path to the Aleo file. let mut aleo_file_path = build.to_path_buf(); aleo_file_path.push(match is_import { - true => format!("{}.{}", program_name, program_id.network()), + true => format!("{program_name}.{}", program_id.network()), false => format!("main.{}", program_id.network()), }); diff --git a/leo/context.rs b/leo/context.rs index bbcdf402bc..4c220caaac 100644 --- a/leo/context.rs +++ b/leo/context.rs @@ -73,7 +73,7 @@ impl Context { let build_manifest_path = build_path.join(Manifest::::file_name()); // Write the file. - File::create(&build_manifest_path) + File::create(build_manifest_path) .map_err(PackageError::failed_to_open_manifest)? .write_all(manifest_string.as_bytes()) .map_err(PackageError::failed_to_open_manifest)?; diff --git a/leo/main.rs b/leo/main.rs index 891284029d..9a9c4d72f8 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -125,7 +125,7 @@ pub fn handle_error(res: Result) -> T { match res { Ok(t) => t, Err(err) => { - eprintln!("{}", err); + eprintln!("{err}"); exit(err.exit_code()); } } diff --git a/leo/package/src/inputs/input.rs b/leo/package/src/inputs/input.rs index ee1b9fa476..41dc602396 100644 --- a/leo/package/src/inputs/input.rs +++ b/leo/package/src/inputs/input.rs @@ -45,7 +45,7 @@ impl InputFile { } pub fn filename(&self) -> String { - format!("{}{}{}", INPUTS_DIRECTORY_NAME, self.package_name, INPUT_FILE_EXTENSION) + format!("{INPUTS_DIRECTORY_NAME}{}{INPUT_FILE_EXTENSION}", self.package_name) } pub fn exists_at(&self, path: &Path) -> bool { @@ -65,7 +65,7 @@ impl InputFile { /// Writes the standard input format to a file. pub fn write_to(self, path: &Path) -> Result<()> { let path = self.setup_file_path(path); - let mut file = File::create(&path).map_err(PackageError::io_error_input_file)?; + let mut file = File::create(path).map_err(PackageError::io_error_input_file)?; file.write_all(self.template().as_bytes()) .map_err(PackageError::io_error_input_file)?; @@ -90,7 +90,7 @@ b: u32 = 2u32; path.to_mut().push(INPUTS_DIRECTORY_NAME); } path.to_mut() - .push(format!("{}{}", self.package_name, INPUT_FILE_EXTENSION)); + .push(format!("{}{INPUT_FILE_EXTENSION}", self.package_name)); } path } diff --git a/leo/package/src/outputs/ast_snapshot.rs b/leo/package/src/outputs/ast_snapshot.rs index 2e7fadec1b..ed1df162d2 100644 --- a/leo/package/src/outputs/ast_snapshot.rs +++ b/leo/package/src/outputs/ast_snapshot.rs @@ -98,7 +98,7 @@ impl SnapshotFile { path.to_mut().push(OUTPUTS_DIRECTORY_NAME); } path.to_mut() - .push(format!("{}{}", self.snapshot, AST_SNAPSHOT_FILE_EXTENSION)); + .push(format!("{}{AST_SNAPSHOT_FILE_EXTENSION}", self.snapshot)); } path } diff --git a/leo/package/src/outputs/checksum.rs b/leo/package/src/outputs/checksum.rs index 07bc19cb10..cc78a14d92 100644 --- a/leo/package/src/outputs/checksum.rs +++ b/leo/package/src/outputs/checksum.rs @@ -60,7 +60,7 @@ impl ChecksumFile { /// Writes the given checksum to a file. pub fn write_to(&self, path: &Path, checksum: String) -> Result<()> { let path = self.setup_file_path(path); - let mut file = File::create(&path).map_err(PackageError::io_error_checksum_file)?; + let mut file = File::create(path).map_err(PackageError::io_error_checksum_file)?; file.write_all(checksum.as_bytes()) .map_err(PackageError::io_error_checksum_file)?; @@ -86,7 +86,7 @@ impl ChecksumFile { path.to_mut().push(OUTPUTS_DIRECTORY_NAME); } path.to_mut() - .push(format!("{}{}", self.package_name, CHECKSUM_FILE_EXTENSION)); + .push(format!("{}{CHECKSUM_FILE_EXTENSION}", self.package_name)); } path } diff --git a/leo/package/src/outputs/circuit.rs b/leo/package/src/outputs/circuit.rs index 313f4b684e..8a1cd225a8 100644 --- a/leo/package/src/outputs/circuit.rs +++ b/leo/package/src/outputs/circuit.rs @@ -60,7 +60,7 @@ impl CircuitFile { /// Writes the given serialized struct to a file. pub fn write_to(&self, path: &Path, circuit: String) -> Result<()> { let path = self.setup_file_path(path); - let mut file = File::create(&path).map_err(PackageError::io_error_circuit_file)?; + let mut file = File::create(path).map_err(PackageError::io_error_circuit_file)?; file.write_all(circuit.as_bytes()) .map_err(PackageError::io_error_circuit_file)?; @@ -86,7 +86,7 @@ impl CircuitFile { path.to_mut().push(OUTPUTS_DIRECTORY_NAME); } path.to_mut() - .push(format!("{}{}", self.package_name, CIRCUIT_FILE_EXTENSION)); + .push(format!("{}{CIRCUIT_FILE_EXTENSION}", self.package_name)); } path } diff --git a/leo/package/src/source/main.rs b/leo/package/src/source/main.rs index f3d3fec761..443f997a73 100644 --- a/leo/package/src/source/main.rs +++ b/leo/package/src/source/main.rs @@ -37,7 +37,7 @@ impl MainFile { } pub fn filename() -> String { - format!("{}{}", SOURCE_DIRECTORY_NAME, MAIN_FILENAME) + format!("{SOURCE_DIRECTORY_NAME}{MAIN_FILENAME}") } pub fn exists_at(path: &Path) -> bool { diff --git a/leo/updater.rs b/leo/updater.rs index ed3a9925fb..71799ba06a 100644 --- a/leo/updater.rs +++ b/leo/updater.rs @@ -45,7 +45,7 @@ impl Updater { } // Forgo using tracing to list the available versions without a log status. - println!("{}", output); + println!("{output}"); Ok(()) } @@ -94,7 +94,7 @@ impl Updater { if let Ok(latest_version) = Self::update_available() { let mut message = "🟢 A new version is available! Run".bold().green().to_string(); message += &" `leo update` ".bold().white(); - message += &format!("to update to v{}.", latest_version).bold().green(); + message += &format!("to update to v{latest_version}.").bold().green(); tracing::info!("\n{}\n", message); } diff --git a/tests/test-framework/benches/leo_compiler.rs b/tests/test-framework/benches/leo_compiler.rs index 202177f767..f0278a700f 100644 --- a/tests/test-framework/benches/leo_compiler.rs +++ b/tests/test-framework/benches/leo_compiler.rs @@ -112,7 +112,7 @@ impl Sample { /// Benchmarks `logic(compiler)` where `compiler` is provided. fn bencher(&self, c: &mut Criterion, mode: &str, mut logic: impl FnMut(Compiler) -> Duration) { - c.bench_function(&format!("{} {}", mode, self.name), |b| { + c.bench_function(&format!("{mode} {}", self.name), |b| { // Iter custom is used so we can use custom timings around the compiler stages. // This way we can only time the necessary stage. b.iter_custom(|iters| { diff --git a/tests/test-framework/src/error.rs b/tests/test-framework/src/error.rs index 48e968e827..7723996542 100644 --- a/tests/test-framework/src/error.rs +++ b/tests/test-framework/src/error.rs @@ -63,7 +63,7 @@ impl fmt::Display for TestError { if test.len() > 50 { String::new() } else { - format!("\n\n{}\n\n", test) + format!("\n\n{test}\n\n") } }; match self { diff --git a/tests/test-framework/src/runner.rs b/tests/test-framework/src/runner.rs index 6cdc2a2cb2..8b7b854608 100644 --- a/tests/test-framework/src/runner.rs +++ b/tests/test-framework/src/runner.rs @@ -67,7 +67,7 @@ fn set_hook() -> Arc>> { *panic_buf.lock().unwrap() = Some(e.to_string()); } } else { - println!("{}", e) + println!("{e}") } }) }); @@ -217,7 +217,7 @@ pub fn run_tests(runner: &T, expectation_category: &str) { let mut expected_output = expectations.as_ref().map(|x| x.outputs.iter()); for (i, test) in tests.into_iter().enumerate() { let expected_output = expected_output.as_mut().and_then(|x| x.next()).cloned(); - println!("running test {} @ '{}'", test_name, path.to_str().unwrap()); + println!("running test {test_name} @ '{}'", path.to_str().unwrap()); let panic_buf = set_hook(); let leo_output = panic::catch_unwind(|| { namespace.run_test(Test { @@ -271,7 +271,7 @@ pub fn run_tests(runner: &T, expectation_category: &str) { ); println!("File: {}", fail.path); for error in &fail.errors { - println!("{}", error); + println!("{error}"); } } panic!(