This commit is contained in:
d0cd 2022-10-24 22:41:10 -07:00
parent a11be415fa
commit df01360010
55 changed files with 193 additions and 197 deletions

View File

@ -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, ", ")?;
}

View File

@ -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}\""),
}
}
}

View File

@ -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::<Vec<_>>()

View File

@ -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
)
}
}

View File

@ -136,7 +136,7 @@ impl Function {
1 => self.output[0].to_string(),
_ => self.output.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
};
write!(f, "({}) -> {} {}", parameters, returns, self.block)
write!(f, "({parameters}) -> {returns} {}", self.block)
}
}

View File

@ -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, "_"),

View File

@ -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.
}
}

View File

@ -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_:?}"),
}
}
}

View File

@ -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)?;

View File

@ -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(())
}

View File

@ -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, "}}")
}

View File

@ -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, ""),
}
}

View File

@ -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})"),
}
}
}

View File

@ -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, ", ")?;
}

View File

@ -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
)
}
}

View File

@ -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, "}}")
}

View File

@ -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"),
}

View File

@ -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.

View File

@ -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<Va
// Write the program string to a file in the temporary directory.
let path = directory.join("main.aleo");
let mut file = File::create(&path).unwrap();
let mut file = File::create(path).unwrap();
file.write_all(bytecode.as_bytes()).unwrap();
// Create the manifest file.
@ -261,7 +261,7 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
// Create the build directory.
let build_directory = directory.join("build");
std::fs::create_dir_all(&build_directory).unwrap();
std::fs::create_dir_all(build_directory).unwrap();
// Open the package at the temporary directory.
let _package = handler.extend_if_error(Package::<Testnet3>::open(&directory).map_err(LeoError::Anyhow))?;

View File

@ -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 {

View File

@ -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 {

View File

@ -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::<Vec<_>>().join(", "))
self.unexpected(tokens.iter().map(|x| format!("'{x}'")).collect::<Vec<_>>().join(", "))
}
}

View File

@ -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)),

View File

@ -68,7 +68,7 @@ impl ParserContext<'_> {
&token.token,
expected
.iter()
.map(|x| format!("'{}'", x))
.map(|x| format!("'{x}'"))
.collect::<Vec<_>>()
.join(", "),
token.span,

View File

@ -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!(

View File

@ -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, "!"),

View File

@ -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.

View File

@ -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"),
}
};

View File

@ -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

View File

@ -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_)),
},
}
}

View File

@ -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;`.

View File

@ -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(),

View File

@ -247,7 +247,7 @@ impl<'a> TypeChecker<'a> {
pub(crate) fn assert_bool_int_type(&self, type_: &Option<Type>, 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<Type>, 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<Type>, 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<Type>, 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<Type>, 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<Type>, 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,
)

View File

@ -162,14 +162,14 @@ impl<'a> Processor<'a> {
.into_iter()
.collect::<HashSet<_>>()
.into_iter()
.map(|tag| format!("[{}](#user-content-{})", &tag, tag))
.map(|tag| format!("[{}](#user-content-{tag})", &tag))
.collect::<Vec<String>>();
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"));
}
}
(_, _) => (),

View File

@ -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}")?;
}
_ => {}
}

View File

@ -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}")?;
}
_ => {}
}

View File

@ -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<i32> {
@ -89,7 +89,7 @@ impl<T: fmt::Display> fmt::Display for Buffer<T> {
x.fmt(f)?;
}
for x in iter {
f.write_fmt(format_args!("\n{}", x))?;
f.write_fmt(format_args!("\n{x}"))?;
}
Ok(())
}

View File

@ -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,
}

View File

@ -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,
}
);

View File

@ -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,
}

View File

@ -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::<Vec<_>>()
.join(", "),
received
.join(", ")
),
help: None,
}

View File

@ -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,
}

View File

@ -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::<Vec<_>>()
.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,
}

View File

@ -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()),
});

View File

@ -73,7 +73,7 @@ impl Context {
let build_manifest_path = build_path.join(Manifest::<Network>::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)?;

View File

@ -125,7 +125,7 @@ pub fn handle_error<T>(res: Result<T>) -> T {
match res {
Ok(t) => t,
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
exit(err.exit_code());
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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);
}

View File

@ -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| {

View File

@ -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 {

View File

@ -67,7 +67,7 @@ fn set_hook() -> Arc<Mutex<Option<String>>> {
*panic_buf.lock().unwrap() = Some(e.to_string());
}
} else {
println!("{}", e)
println!("{e}")
}
})
});
@ -217,7 +217,7 @@ pub fn run_tests<T: Runner>(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<T: Runner>(runner: &T, expectation_category: &str) {
);
println!("File: {}", fail.path);
for error in &fail.errors {
println!("{}", error);
println!("{error}");
}
}
panic!(