chore: clippy autofix

This commit is contained in:
rvcas 2023-02-01 13:08:54 -05:00 committed by Lucas
parent 4530507109
commit a365649360
24 changed files with 104 additions and 110 deletions

View File

@ -1188,7 +1188,7 @@ pub fn expr_parser(
.map(|(index, a)| match a { .map(|(index, a)| match a {
ParserArg::Arg(arg) => *arg, ParserArg::Arg(arg) => *arg,
ParserArg::Hole { location, label } => { ParserArg::Hole { location, label } => {
let name = format!("{}__{}", CAPTURE_VARIABLE, index); let name = format!("{CAPTURE_VARIABLE}__{index}");
holes.push(ast::Arg { holes.push(ast::Arg {
location: Span::empty(), location: Span::empty(),
annotation: None, annotation: None,
@ -1205,7 +1205,7 @@ pub fn expr_parser(
location, location,
value: expr::UntypedExpr::Var { value: expr::UntypedExpr::Var {
location, location,
name: format!("{}__{}", CAPTURE_VARIABLE, index), name: format!("{CAPTURE_VARIABLE}__{index}"),
}, },
} }
} }

View File

@ -84,7 +84,7 @@ impl fmt::Display for Token {
let index_str; let index_str;
let s = match self { let s = match self {
Token::Error(c) => { Token::Error(c) => {
write!(f, "\"{}\"", c)?; write!(f, "\"{c}\"")?;
return Ok(()); return Ok(());
} }
Token::Name { name } => name, Token::Name { name } => name,
@ -159,6 +159,6 @@ impl fmt::Display for Token {
Token::Test => "test", Token::Test => "test",
Token::ErrorTerm => "error", Token::ErrorTerm => "error",
}; };
write!(f, "\"{}\"", s) write!(f, "\"{s}\"")
} }
} }

View File

@ -37,7 +37,7 @@ pub trait Documentable<'a> {
impl<'a> Documentable<'a> for char { impl<'a> Documentable<'a> for char {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
@ -49,49 +49,49 @@ impl<'a> Documentable<'a> for &'a str {
impl<'a> Documentable<'a> for isize { impl<'a> Documentable<'a> for isize {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
impl<'a> Documentable<'a> for i64 { impl<'a> Documentable<'a> for i64 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
impl<'a> Documentable<'a> for usize { impl<'a> Documentable<'a> for usize {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
impl<'a> Documentable<'a> for f64 { impl<'a> Documentable<'a> for f64 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{:?}", self)) Document::String(format!("{self:?}"))
} }
} }
impl<'a> Documentable<'a> for u64 { impl<'a> Documentable<'a> for u64 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{:?}", self)) Document::String(format!("{self:?}"))
} }
} }
impl<'a> Documentable<'a> for u32 { impl<'a> Documentable<'a> for u32 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
impl<'a> Documentable<'a> for u16 { impl<'a> Documentable<'a> for u16 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }
impl<'a> Documentable<'a> for u8 { impl<'a> Documentable<'a> for u8 {
fn to_doc(self) -> Document<'a> { fn to_doc(self) -> Document<'a> {
Document::String(format!("{}", self)) Document::String(format!("{self}"))
} }
} }

View File

@ -756,7 +756,7 @@ impl<'a> CodeGenerator<'a> {
if next_list_size == current_clause_index { if next_list_size == current_clause_index {
None None
} else { } else {
Some(format!("__tail_{}", current_clause_index)) Some(format!("__tail_{current_clause_index}"))
} }
}; };
@ -1344,7 +1344,7 @@ impl<'a> CodeGenerator<'a> {
current_index: index as i64, current_index: index as i64,
}; };
let tail_name = format!("{}_{}", new_tail_name, index); let tail_name = format!("{new_tail_name}_{index}");
if elements.len() - 1 == index { if elements.len() - 1 == index {
if tail.is_some() { if tail.is_some() {
@ -1969,11 +1969,11 @@ impl<'a> CodeGenerator<'a> {
current_index += 1; current_index += 1;
} else { } else {
let id_next = self.id_gen.next(); let id_next = self.id_gen.next();
final_args.push((format!("__field_{index}_{}", id_next), index)); final_args.push((format!("__field_{index}_{id_next}"), index));
self.recursive_assert_tipo( self.recursive_assert_tipo(
type_map.get(&index).unwrap(), type_map.get(&index).unwrap(),
&mut nested_pattern, &mut nested_pattern,
&format!("__field_{index}_{}", id_next), &format!("__field_{index}_{id_next}"),
scope.clone(), scope.clone(),
) )
} }
@ -2068,11 +2068,11 @@ impl<'a> CodeGenerator<'a> {
current_index += 1; current_index += 1;
} else { } else {
let id_next = self.id_gen.next(); let id_next = self.id_gen.next();
final_args.push((format!("__tuple_{index}_{}", id_next), index)); final_args.push((format!("__tuple_{index}_{id_next}"), index));
self.recursive_assert_tipo( self.recursive_assert_tipo(
type_map.get(&index).unwrap(), type_map.get(&index).unwrap(),
&mut nested_pattern, &mut nested_pattern,
&format!("__tuple_{index}_{}", id_next), &format!("__tuple_{index}_{id_next}"),
scope.clone(), scope.clone(),
) )
} }
@ -2159,7 +2159,7 @@ impl<'a> CodeGenerator<'a> {
assert_vec.push(Air::Fn { assert_vec.push(Air::Fn {
scope: scope.clone(), scope: scope.clone(),
params: vec![format!("__pair_{}", new_id)], params: vec![format!("__pair_{new_id}")],
}); });
assert_vec.push(Air::TupleAccessor { assert_vec.push(Air::TupleAccessor {
@ -2180,7 +2180,7 @@ impl<'a> CodeGenerator<'a> {
location: Span::empty(), location: Span::empty(),
}, },
), ),
name: format!("__pair_{}", new_id), name: format!("__pair_{new_id}"),
variant_name: String::new(), variant_name: String::new(),
}); });
@ -2248,12 +2248,12 @@ impl<'a> CodeGenerator<'a> {
assert_vec.push(Air::Fn { assert_vec.push(Air::Fn {
scope: scope.clone(), scope: scope.clone(),
params: vec![format!("__list_item_{}", new_id)], params: vec![format!("__list_item_{new_id}")],
}); });
assert_vec.push(Air::Let { assert_vec.push(Air::Let {
scope: scope.clone(), scope: scope.clone(),
name: format!("__list_item_{}", new_id), name: format!("__list_item_{new_id}"),
}); });
assert_vec.push(Air::UnWrapData { assert_vec.push(Air::UnWrapData {
@ -2269,14 +2269,14 @@ impl<'a> CodeGenerator<'a> {
location: Span::empty(), location: Span::empty(),
}, },
), ),
name: format!("__list_item_{}", new_id), name: format!("__list_item_{new_id}"),
variant_name: String::new(), variant_name: String::new(),
}); });
self.recursive_assert_tipo( self.recursive_assert_tipo(
inner_list_type, inner_list_type,
assert_vec, assert_vec,
&format!("__list_item_{}", new_id), &format!("__list_item_{new_id}"),
scope.clone(), scope.clone(),
); );
@ -2292,7 +2292,7 @@ impl<'a> CodeGenerator<'a> {
scope: scope.clone(), scope: scope.clone(),
names: new_id_list names: new_id_list
.iter() .iter()
.map(|(index, id)| format!("__tuple_index_{}_{}", index, id)) .map(|(index, id)| format!("__tuple_index_{index}_{id}"))
.collect_vec(), .collect_vec(),
tipo: tipo.clone().into(), tipo: tipo.clone().into(),
check_last_item: true, check_last_item: true,
@ -2312,7 +2312,7 @@ impl<'a> CodeGenerator<'a> {
for (index, name) in new_id_list for (index, name) in new_id_list
.into_iter() .into_iter()
.map(|(index, id)| (index, format!("__tuple_index_{}_{}", index, id))) .map(|(index, id)| (index, format!("__tuple_index_{index}_{id}")))
{ {
self.recursive_assert_tipo( self.recursive_assert_tipo(
&tuple_inner_types[index], &tuple_inner_types[index],
@ -2340,7 +2340,7 @@ impl<'a> CodeGenerator<'a> {
assert_vec.push(Air::When { assert_vec.push(Air::When {
scope: scope.clone(), scope: scope.clone(),
tipo: tipo.clone().into(), tipo: tipo.clone().into(),
subject_name: format!("__subject_{}", new_id), subject_name: format!("__subject_{new_id}"),
}); });
assert_vec.push(Air::Var { assert_vec.push(Air::Var {
@ -2364,7 +2364,7 @@ impl<'a> CodeGenerator<'a> {
let arg_name = arg let arg_name = arg
.label .label
.clone() .clone()
.unwrap_or(format!("__field_{}_{}", index, new_id)); .unwrap_or(format!("__field_{index}_{new_id}"));
(index, arg_name, arg.tipo.clone()) (index, arg_name, arg.tipo.clone())
}) })
.collect_vec(); .collect_vec();
@ -2372,7 +2372,7 @@ impl<'a> CodeGenerator<'a> {
assert_vec.push(Air::Clause { assert_vec.push(Air::Clause {
scope: scope.clone(), scope: scope.clone(),
tipo: tipo.clone().into(), tipo: tipo.clone().into(),
subject_name: format!("__subject_{}", new_id), subject_name: format!("__subject_{new_id}"),
complex_clause: false, complex_clause: false,
}); });
@ -3716,7 +3716,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::HeadList).force_wrap(), Term::Builtin(DefaultFunction::HeadList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__list_{}", list_id), text: format!("__list_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -3728,7 +3728,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::HeadList).force_wrap(), Term::Builtin(DefaultFunction::HeadList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__list_{}", list_id), text: format!("__list_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -3748,7 +3748,7 @@ impl<'a> CodeGenerator<'a> {
term = apply_wrap( term = apply_wrap(
Term::Lambda { Term::Lambda {
parameter_name: Name { parameter_name: Name {
text: format!("__list_{}", list_id), text: format!("__list_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -3773,7 +3773,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::TailList).force_wrap(), Term::Builtin(DefaultFunction::TailList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__list_{}", list_id), text: format!("__list_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -3953,7 +3953,7 @@ impl<'a> CodeGenerator<'a> {
term, term,
Term::Var( Term::Var(
Name { Name {
text: format!("__arg_{}", id), text: format!("__arg_{id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -3969,7 +3969,7 @@ impl<'a> CodeGenerator<'a> {
term = convert_data_to_type(term, &inner_type); term = convert_data_to_type(term, &inner_type);
term = Term::Lambda { term = Term::Lambda {
parameter_name: Name { parameter_name: Name {
text: format!("__arg_{}", id), text: format!("__arg_{id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -4039,7 +4039,7 @@ impl<'a> CodeGenerator<'a> {
arg_stack.push(term); arg_stack.push(term);
return; return;
} else if tipo.is_tuple() } else if tipo.is_tuple()
&& matches!(tipo.clone().get_uplc_type(), UplcType::Pair(_, _)) && matches!(tipo.get_uplc_type(), UplcType::Pair(_, _))
{ {
let term = apply_wrap( let term = apply_wrap(
apply_wrap( apply_wrap(
@ -4134,7 +4134,7 @@ impl<'a> CodeGenerator<'a> {
arg_stack.push(term); arg_stack.push(term);
return; return;
} else if tipo.is_tuple() } else if tipo.is_tuple()
&& matches!(tipo.clone().get_uplc_type(), UplcType::Pair(_, _)) && matches!(tipo.get_uplc_type(), UplcType::Pair(_, _))
{ {
let mut term = apply_wrap( let mut term = apply_wrap(
apply_wrap( apply_wrap(
@ -5030,7 +5030,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::HeadList).force_wrap(), Term::Builtin(DefaultFunction::HeadList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__constr_fields_{}", list_id), text: format!("__constr_fields_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5057,7 +5057,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::TailList).force_wrap(), Term::Builtin(DefaultFunction::TailList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__constr_fields_{}", list_id), text: format!("__constr_fields_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5071,7 +5071,7 @@ impl<'a> CodeGenerator<'a> {
term = apply_wrap( term = apply_wrap(
Term::Lambda { Term::Lambda {
parameter_name: Name { parameter_name: Name {
text: format!("__constr_fields_{}", list_id), text: format!("__constr_fields_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5260,7 +5260,7 @@ impl<'a> CodeGenerator<'a> {
if !unchanged_field_indices.is_empty() { if !unchanged_field_indices.is_empty() {
prev_index = highest_index; prev_index = highest_index;
for index in unchanged_field_indices.into_iter() { for index in unchanged_field_indices.into_iter() {
let tail_name = format!("{tail_name_prefix}_{}", prev_index); let tail_name = format!("{tail_name_prefix}_{prev_index}");
let prev_tail_name = format!("{tail_name_prefix}_{index}"); let prev_tail_name = format!("{tail_name_prefix}_{index}");
let mut tail_list = Term::Var( let mut tail_list = Term::Var(
@ -5429,7 +5429,7 @@ impl<'a> CodeGenerator<'a> {
term = apply_wrap( term = apply_wrap(
Term::Lambda { Term::Lambda {
parameter_name: Name { parameter_name: Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5456,7 +5456,7 @@ impl<'a> CodeGenerator<'a> {
.force_wrap(), .force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5474,7 +5474,7 @@ impl<'a> CodeGenerator<'a> {
.force_wrap(), .force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5502,7 +5502,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::HeadList).force_wrap(), Term::Builtin(DefaultFunction::HeadList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5514,7 +5514,7 @@ impl<'a> CodeGenerator<'a> {
term = apply_wrap( term = apply_wrap(
Term::Lambda { Term::Lambda {
parameter_name: Name { parameter_name: Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),
@ -5539,7 +5539,7 @@ impl<'a> CodeGenerator<'a> {
Term::Builtin(DefaultFunction::TailList).force_wrap(), Term::Builtin(DefaultFunction::TailList).force_wrap(),
Term::Var( Term::Var(
Name { Name {
text: format!("__tuple_{}", list_id), text: format!("__tuple_{list_id}"),
unique: 0.into(), unique: 0.into(),
} }
.into(), .into(),

View File

@ -133,7 +133,7 @@ impl Server {
id, id,
error: Some(lsp_server::ResponseError { error: Some(lsp_server::ResponseError {
code: 1, // We should assign a code to each error. code: 1, // We should assign a code to each error.
message: format!("{:?}", error), message: format!("{error:?}"),
data: None, data: None,
}), }),
result: None, result: None,

View File

@ -124,7 +124,7 @@ impl TryFrom<String> for Purpose {
"mint" => Ok(Purpose::Mint), "mint" => Ok(Purpose::Mint),
"withdraw" => Ok(Purpose::Withdraw), "withdraw" => Ok(Purpose::Withdraw),
"publish" => Ok(Purpose::Publish), "publish" => Ok(Purpose::Publish),
unexpected => Err(format!("Can't turn '{}' into any Purpose", unexpected)), unexpected => Err(format!("Can't turn '{unexpected}' into any Purpose")),
} }
} }
} }
@ -248,7 +248,7 @@ mod test {
let validator = Validator::from_checked_module(&modules, &mut generator, validator, def) let validator = Validator::from_checked_module(&modules, &mut generator, validator, def)
.expect("Failed to create validator blueprint"); .expect("Failed to create validator blueprint");
println!("{}", validator); println!("{validator}");
assert_json_eq!(serde_json::to_value(&validator).unwrap(), json); assert_json_eq!(serde_json::to_value(&validator).unwrap(), json);
} }

View File

@ -156,10 +156,10 @@ impl Error {
match self { match self {
Error::List(errors) => { Error::List(errors) => {
for error in errors { for error in errors {
eprintln!("Error: {:?}", error) eprintln!("Error: {error:?}")
} }
} }
rest => eprintln!("Error: {:?}", rest), rest => eprintln!("Error: {rest:?}"),
} }
} }
@ -581,7 +581,7 @@ impl Warning {
} }
pub fn report(&self) { pub fn report(&self) {
eprintln!("Warning: {:?}", self) eprintln!("Warning: {self:?}")
} }
} }

View File

@ -31,7 +31,7 @@ fn process_stdin(check: bool) -> Result<(), Error> {
aiken_lang::format::pretty(&mut out, module, extra, &src); aiken_lang::format::pretty(&mut out, module, extra, &src);
if !check { if !check {
print!("{}", out); print!("{out}");
return Ok(()); return Ok(());
} }

View File

@ -116,7 +116,7 @@ pub fn exec(
println!("cpu: {}", total_budget_used.cpu); println!("cpu: {}", total_budget_used.cpu);
} }
Err(err) => { Err(err) => {
eprintln!("\nError\n-----\n\n{}\n", err); eprintln!("\nError\n-----\n\n{err}\n");
} }
} }
} }

View File

@ -72,7 +72,7 @@ pub fn exec(
println!("\nResult\n------\n\n{}\n", term.to_pretty()); println!("\nResult\n------\n\n{}\n", term.to_pretty());
} }
Err(err) => { Err(err) => {
eprintln!("\nError\n-----\n\n{}\n", err); eprintln!("\nError\n-----\n\n{err}\n");
} }
} }

View File

@ -44,7 +44,7 @@ pub fn exec(
let mut output = String::new(); let mut output = String::new();
for (i, byte) in bytes.iter().enumerate() { for (i, byte) in bytes.iter().enumerate() {
let _ = write!(output, "{:08b}", byte); let _ = write!(output, "{byte:08b}");
if (i + 1) % 4 == 0 { if (i + 1) % 4 == 0 {
output.push('\n'); output.push('\n');
@ -53,7 +53,7 @@ pub fn exec(
} }
} }
println!("{}", output); println!("{output}");
} else { } else {
let out_name = if let Some(out) = out { let out_name = if let Some(out) = out {
out out

View File

@ -21,7 +21,7 @@ pub fn exec(Args { input, print }: Args) -> miette::Result<()> {
let pretty = program.to_pretty(); let pretty = program.to_pretty();
if print { if print {
println!("{}", pretty); println!("{pretty}");
} else { } else {
fs::write(&input, pretty).into_diagnostic()?; fs::write(&input, pretty).into_diagnostic()?;
} }

View File

@ -47,7 +47,7 @@ pub fn exec(
let pretty = program.to_pretty(); let pretty = program.to_pretty();
if print { if print {
println!("{}", pretty); println!("{pretty}");
} else { } else {
let out_name = if let Some(out) = out { let out_name = if let Some(out) = out {
out out

View File

@ -38,7 +38,7 @@ where
err.report(); err.report();
println!("\n{}", "Summary".purple().bold()); println!("\n{}", "Summary".purple().bold());
let warning_text = format!("{warning_count} warning{}", plural); let warning_text = format!("{warning_count} warning{plural}");
let plural = if err.len() == 1 { "" } else { "s" }; let plural = if err.len() == 1 { "" } else { "s" };
@ -46,13 +46,13 @@ where
let full_summary = format!(" {}, {}", error_text.red(), warning_text.yellow()); let full_summary = format!(" {}, {}", error_text.red(), warning_text.yellow());
println!("{}", full_summary); println!("{full_summary}");
process::exit(1); process::exit(1);
} else { } else {
println!("\n{}", "Summary".purple().bold()); println!("\n{}", "Summary".purple().bold());
let warning_text = format!("{warning_count} warning{}", plural); let warning_text = format!("{warning_count} warning{plural}");
println!(" 0 errors, {}", warning_text.yellow(),); println!(" 0 errors, {}", warning_text.yellow(),);
} }
@ -169,8 +169,8 @@ impl telemetry::EventListener for Terminal {
let elapsed = format!("{:.2}s", start.elapsed().as_millis() as f32 / 1000.); let elapsed = format!("{:.2}s", start.elapsed().as_millis() as f32 / 1000.);
let msg = match count { let msg = match count {
1 => format!("1 package in {}", elapsed), 1 => format!("1 package in {elapsed}"),
_ => format!("{} packages in {}", count, elapsed), _ => format!("{count} packages in {elapsed}"),
}; };
println!("{} {}", " Downloaded".bold().purple(), msg.bold()) println!("{} {}", " Downloaded".bold().purple(), msg.bold())
@ -244,11 +244,11 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
.bold() .bold()
.to_string()), .to_string()),
pretty::style_if(styled, format!("{} passed", n_passed), |s| s pretty::style_if(styled, format!("{n_passed} passed"), |s| s
.bright_green() .bright_green()
.bold() .bold()
.to_string()), .to_string()),
pretty::style_if(styled, format!("{} failed", n_failed), |s| s pretty::style_if(styled, format!("{n_failed} failed"), |s| s
.bright_red() .bright_red()
.bold() .bold()
.to_string()), .to_string()),
@ -273,7 +273,7 @@ fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
pretty::pad_left(cpu.to_string(), max_cpu, " "), pretty::pad_left(cpu.to_string(), max_cpu, " "),
output output
.as_ref() .as_ref()
.map(|x| format!("{}", x)) .map(|x| format!("{x}"))
.unwrap_or_else(|| "Error.".to_string()), .unwrap_or_else(|| "Error.".to_string()),
) )
} }

View File

@ -11,5 +11,5 @@ impl<T: WithTerm> WithIdentity for T {}
fn main() { fn main() {
let my_var = "some_var"; let my_var = "some_var";
let program = Builder::start(1, 2, 3).with_identity(my_var).build_named(); let program = Builder::start(1, 2, 3).with_identity(my_var).build_named();
println!("{:#?}", program); println!("{program:#?}");
} }

View File

@ -144,7 +144,7 @@ impl<'a> Deserialize<'a> for Program<DeBruijn> {
Program::<DeBruijn>::from_hex(&compiled_code, &mut cbor_buffer, &mut flat_buffer) Program::<DeBruijn>::from_hex(&compiled_code, &mut cbor_buffer, &mut flat_buffer)
.map_err(|e| { .map_err(|e| {
de::Error::invalid_value( de::Error::invalid_value(
de::Unexpected::Other(&format!("{}", e)), de::Unexpected::Other(&format!("{e}")),
&"a base16-encoded CBOR-serialized UPLC program", &"a base16-encoded CBOR-serialized UPLC program",
) )
}) })
@ -266,8 +266,8 @@ impl Display for Type {
Type::String => write!(f, "string"), Type::String => write!(f, "string"),
Type::ByteString => write!(f, "bytestring"), Type::ByteString => write!(f, "bytestring"),
Type::Unit => write!(f, "unit"), Type::Unit => write!(f, "unit"),
Type::List(t) => write!(f, "list {}", t), Type::List(t) => write!(f, "list {t}"),
Type::Pair(t1, t2) => write!(f, "pair {} {}", t1, t2), Type::Pair(t1, t2) => write!(f, "pair {t1} {t2}"),
Type::Data => write!(f, "data"), Type::Data => write!(f, "data"),
} }
} }

View File

@ -192,8 +192,7 @@ impl TryFrom<u8> for DefaultFunction {
v if v == DefaultFunction::MkNilData as u8 => Ok(DefaultFunction::MkNilData), v if v == DefaultFunction::MkNilData as u8 => Ok(DefaultFunction::MkNilData),
v if v == DefaultFunction::MkNilPairData as u8 => Ok(DefaultFunction::MkNilPairData), v if v == DefaultFunction::MkNilPairData as u8 => Ok(DefaultFunction::MkNilPairData),
_ => Err(de::Error::Message(format!( _ => Err(de::Error::Message(format!(
"Default Function not found - {}", "Default Function not found - {v}"
v
))), ))),
} }
} }
@ -260,7 +259,7 @@ impl FromStr for DefaultFunction {
"mkPairData" => Ok(MkPairData), "mkPairData" => Ok(MkPairData),
"mkNilData" => Ok(MkNilData), "mkNilData" => Ok(MkNilData),
"mkNilPairData" => Ok(MkNilPairData), "mkNilPairData" => Ok(MkNilPairData),
rest => Err(format!("Default Function not found - {}", rest)), rest => Err(format!("Default Function not found - {rest}")),
} }
} }
} }

View File

@ -179,7 +179,7 @@ impl Converter {
Term::Var( Term::Var(
Name { Name {
text: format!("i_{}", unique), text: format!("i_{unique}"),
unique, unique,
} }
.into(), .into(),
@ -195,7 +195,7 @@ impl Converter {
let unique = self.get_unique(parameter_name)?; let unique = self.get_unique(parameter_name)?;
let name = Name { let name = Name {
text: format!("i_{}", unique), text: format!("i_{unique}"),
unique, unique,
}; };
@ -251,7 +251,7 @@ impl Converter {
match term { match term {
Term::Var(name) => Term::Var( Term::Var(name) => Term::Var(
NamedDeBruijn { NamedDeBruijn {
text: format!("i_{}", name), text: format!("i_{name}"),
index: *name.as_ref(), index: *name.as_ref(),
} }
.into(), .into(),

View File

@ -207,7 +207,7 @@ where
Err(de::Error::UnknownTermConstructor( Err(de::Error::UnknownTermConstructor(
x, x,
if d.pos > 5 { 5 } else { d.pos }, if d.pos > 5 { 5 } else { d.pos },
format!("{:02X?}", buffer_slice), format!("{buffer_slice:02X?}"),
d.pos, d.pos,
d.buffer.len(), d.buffer.len(),
)) ))
@ -347,7 +347,7 @@ where
let builtin_option = DefaultFunction::decode(d); let builtin_option = DefaultFunction::decode(d);
match builtin_option { match builtin_option {
Ok(builtin) => { Ok(builtin) => {
state_log.push(format!("{})", builtin)); state_log.push(format!("{builtin})"));
Ok(Term::Builtin(builtin)) Ok(Term::Builtin(builtin))
} }
Err(error) => { Err(error) => {
@ -371,7 +371,7 @@ where
Err(de::Error::UnknownTermConstructor( Err(de::Error::UnknownTermConstructor(
x, x,
if d.pos > 5 { 5 } else { d.pos }, if d.pos > 5 { 5 } else { d.pos },
format!("{:02X?}", buffer_slice), format!("{buffer_slice:02X?}"),
d.pos, d.pos,
d.buffer.len(), d.buffer.len(),
)) ))
@ -526,8 +526,7 @@ impl<'b> Decode<'b> for Constant {
Ok(Constant::Data(data)) Ok(Constant::Data(data))
} }
x => Err(de::Error::Message(format!( x => Err(de::Error::Message(format!(
"Unknown constant constructor tag: {:?}", "Unknown constant constructor tag: {x:?}"
x
))), ))),
} }
} }
@ -586,21 +585,18 @@ fn decode_type(types: &mut VecDeque<u8>) -> Result<Type, de::Error> {
Ok(Type::Pair(type1.into(), type2.into())) Ok(Type::Pair(type1.into(), type2.into()))
} }
Some(x) => Err(de::Error::Message(format!( Some(x) => Err(de::Error::Message(format!(
"Unknown constant type tag: {}", "Unknown constant type tag: {x}"
x
))), ))),
None => Err(de::Error::Message("Unexpected empty buffer".to_string())), None => Err(de::Error::Message("Unexpected empty buffer".to_string())),
}, },
Some(x) => Err(de::Error::Message(format!( Some(x) => Err(de::Error::Message(format!(
"Unknown constant type tag: {}", "Unknown constant type tag: {x}"
x
))), ))),
None => Err(de::Error::Message("Unexpected empty buffer".to_string())), None => Err(de::Error::Message("Unexpected empty buffer".to_string())),
}, },
Some(x) => Err(de::Error::Message(format!( Some(x) => Err(de::Error::Message(format!(
"Unknown constant type tag: {}", "Unknown constant type tag: {x}"
x
))), ))),
None => Err(de::Error::Message("Unexpected empty buffer".to_string())), None => Err(de::Error::Message("Unexpected empty buffer".to_string())),
} }
@ -779,8 +775,7 @@ fn decode_term_tag(d: &mut Decoder) -> Result<u8, de::Error> {
fn safe_encode_bits(num_bits: u32, byte: u8, e: &mut Encoder) -> Result<(), en::Error> { fn safe_encode_bits(num_bits: u32, byte: u8, e: &mut Encoder) -> Result<(), en::Error> {
if 2_u8.pow(num_bits) < byte { if 2_u8.pow(num_bits) < byte {
Err(en::Error::Message(format!( Err(en::Error::Message(format!(
"Overflow detected, cannot fit {} in {} bits.", "Overflow detected, cannot fit {byte} in {num_bits} bits."
byte, num_bits
))) )))
} else { } else {
e.bits(num_bits as i64, byte); e.bits(num_bits as i64, byte);

View File

@ -676,7 +676,7 @@ impl DefaultFunction {
(Value::Con(string1), Value::Con(string2)) => { (Value::Con(string1), Value::Con(string2)) => {
match (string1.as_ref(), string2.as_ref()) { match (string1.as_ref(), string2.as_ref()) {
(Constant::String(arg1), Constant::String(arg2)) => Ok(Value::Con( (Constant::String(arg1), Constant::String(arg2)) => Ok(Value::Con(
Constant::String(format!("{}{}", arg1, arg2)).into(), Constant::String(format!("{arg1}{arg2}")).into(),
)), )),
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -46,8 +46,8 @@ mod tests {
) { ) {
let code = format!(r"(program let code = format!(r"(program
11.22.33 11.22.33
(con integer {}) (con integer {int})
)", int); )");
let expected = parser::program(&code).unwrap(); let expected = parser::program(&code).unwrap();
let actual = Builder::start(11, 22, 33).with_int(int).build_named(); let actual = Builder::start(11, 22, 33).with_int(int).build_named();
assert_eq!(expected, actual); assert_eq!(expected, actual);
@ -62,8 +62,8 @@ mod tests {
let bstring = hex::encode(&bytes); let bstring = hex::encode(&bytes);
let code = format!(r"(program let code = format!(r"(program
11.22.33 11.22.33
(con bytestring #{}) (con bytestring #{bstring})
)", bstring); )");
let expected = parser::program(&code).unwrap(); let expected = parser::program(&code).unwrap();
let actual = Builder::start(11, 22, 33) let actual = Builder::start(11, 22, 33)
.with_byte_string(bytes) .with_byte_string(bytes)

View File

@ -23,9 +23,9 @@ proptest! {
(maj, min, patch) in arb_version(), (maj, min, patch) in arb_version(),
) { ) {
let code = format!(r"(program let code = format!(r"(program
{}.{}.{} {maj}.{min}.{patch}
(con integer 11) (con integer 11)
)", maj, min, patch); )");
let expected = parser::program(&code).unwrap(); let expected = parser::program(&code).unwrap();
let actual = Builder::start(maj, min, patch).with_int(11).build_named(); let actual = Builder::start(maj, min, patch).with_int(11).build_named();
assert_eq!(expected, actual); assert_eq!(expected, actual);

View File

@ -48,13 +48,13 @@ pub fn validate_missing_scripts(
.clone() .clone()
.into_iter() .into_iter()
.filter(|x| !received_hashes.contains(x)) .filter(|x| !received_hashes.contains(x))
.map(|x| format!("[Missing (sh: {})]", x)) .map(|x| format!("[Missing (sh: {x})]"))
.collect(); .collect();
let extra: Vec<_> = received_hashes let extra: Vec<_> = received_hashes
.into_iter() .into_iter()
.filter(|x| !needed_hashes.contains(x)) .filter(|x| !needed_hashes.contains(x))
.map(|x| format!("[Extraneous (sh: {:?})]", x)) .map(|x| format!("[Extraneous (sh: {x:?})]"))
.collect(); .collect();
if !missing.is_empty() || !extra.is_empty() { if !missing.is_empty() || !extra.is_empty() {
@ -206,7 +206,7 @@ pub fn has_exact_set_of_redeemers(
let extra: Vec<_> = wits_redeemer_ptrs let extra: Vec<_> = wits_redeemer_ptrs
.into_iter() .into_iter()
.filter(|x| !needed_redeemer_ptrs.contains(x)) .filter(|x| !needed_redeemer_ptrs.contains(x))
.map(|x| format!("[Extraneous (redeemer_ptr: {:?})]", x)) .map(|x| format!("[Extraneous (redeemer_ptr: {x:?})]"))
.collect(); .collect();
if !missing.is_empty() || !extra.is_empty() { if !missing.is_empty() || !extra.is_empty() {

View File

@ -259,7 +259,7 @@ fn test_eval() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -529,7 +529,7 @@ fn test_eval_1() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -634,7 +634,7 @@ fn test_eval_2() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -898,7 +898,7 @@ fn test_eval_3() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -1082,7 +1082,7 @@ fn test_eval_5() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -1186,7 +1186,7 @@ fn test_eval_6() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -1290,7 +1290,7 @@ fn test_eval_7() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,
@ -1545,7 +1545,7 @@ fn test_eval_8() {
cpu: accum.cpu + curr.ex_units.steps as i64, cpu: accum.cpu + curr.ex_units.steps as i64,
}); });
println!("{:?}", total_budget_used); println!("{total_budget_used:?}");
assert_eq!( assert_eq!(
total_budget_used, total_budget_used,