From ed1bc39c67a7d9b9d0b9ddf4454b4e8ca56c8984 Mon Sep 17 00:00:00 2001 From: Nick Furfaro Date: Thu, 26 Jan 2023 14:05:13 -0700 Subject: [PATCH] Run `cargo clippy --fix` in the sway repo (#3903) Co-authored-by: Sophie --- forc-pkg/src/lock.rs | 10 +- forc-pkg/src/manifest.rs | 6 +- forc-pkg/src/pkg.rs | 52 +++--- forc-plugins/forc-client/src/ops/tx_util.rs | 2 +- forc-plugins/forc-doc/src/doc.rs | 2 +- forc-plugins/forc-doc/src/render.rs | 16 +- forc-plugins/forc-fmt/src/main.rs | 8 +- forc-plugins/forc-tx/src/lib.rs | 12 +- forc-plugins/forc-tx/src/main.rs | 2 +- forc-util/src/lib.rs | 6 +- forc/src/cli/commands/addr2line.rs | 2 +- forc/src/cli/commands/plugins.rs | 2 +- forc/src/utils/program_type.rs | 2 +- scripts/examples-checker/src/main.rs | 7 +- .../src/bin/mdbook-forc-documenter.rs | 2 +- .../mdbook-forc-documenter/src/formatter.rs | 2 +- scripts/mdbook-forc-documenter/src/lib.rs | 5 +- sway-ast/src/intrinsics.rs | 2 +- .../fuel/abstract_instruction_set.rs | 2 +- .../allocated_abstract_instruction_set.rs | 4 +- .../src/asm_generation/fuel/data_section.rs | 2 +- .../asm_generation/fuel/fuel_asm_builder.rs | 12 +- .../src/asm_generation/fuel/functions.rs | 14 +- .../src/asm_generation/instruction_set.rs | 4 +- .../src/asm_generation/programs/final.rs | 4 +- sway-core/src/asm_lang/allocated_ops.rs | 162 ++++++++--------- sway-core/src/asm_lang/mod.rs | 172 +++++++++--------- sway-core/src/asm_lang/virtual_register.rs | 4 +- sway-core/src/concurrent_slab.rs | 2 +- .../dead_code_analysis.rs | 12 +- .../control_flow_analysis/flow_graph/mod.rs | 4 +- sway-core/src/decl_engine/engine.rs | 2 +- sway-core/src/decl_engine/mapping.rs | 2 +- sway-core/src/ir_generation/function.rs | 10 +- sway-core/src/ir_generation/storage.rs | 2 +- sway-core/src/ir_generation/types.rs | 2 +- sway-core/src/language/call_path.rs | 2 +- sway-core/src/language/literal.rs | 2 +- .../ty/expression/expression_variant.rs | 16 +- .../language/ty/expression/reassignment.rs | 2 +- .../ast_node/declaration/impl_trait.rs | 2 +- .../match_expression/analysis/patstack.rs | 4 +- .../match_expression/analysis/pattern.rs | 30 +-- .../match_expression/analysis/range.rs | 4 +- .../analysis/witness_report.rs | 4 +- .../ast_node/expression/typed_expression.rs | 2 +- .../src/semantic_analysis/namespace/module.rs | 4 +- .../semantic_analysis/namespace/namespace.rs | 4 +- .../semantic_analysis/node_dependencies.rs | 4 +- sway-core/src/type_system/engine.rs | 2 +- sway-core/src/type_system/info.rs | 8 +- sway-core/src/type_system/substitute.rs | 2 +- sway-error/src/error.rs | 4 +- sway-error/src/type_error.rs | 2 +- sway-error/src/warning.rs | 22 +-- sway-ir/src/analysis/dominator.rs | 4 +- sway-ir/src/function.rs | 6 +- sway-ir/src/irtype.rs | 4 +- sway-ir/src/optimize/inline.rs | 2 +- sway-ir/src/printer.rs | 4 +- sway-ir/sway-ir-macros/src/lib.rs | 2 +- sway-ir/tests/tests.rs | 2 +- sway-lsp/src/capabilities/diagnostic.rs | 2 +- sway-lsp/src/capabilities/hover.rs | 6 +- sway-lsp/src/core/document.rs | 2 +- sway-lsp/src/core/session.rs | 2 +- sway-lsp/src/server.rs | 4 +- sway-lsp/src/utils/debug.rs | 20 +- sway-lsp/src/utils/markup.rs | 2 +- sway-parse/src/attribute.rs | 2 +- sway-parse/src/expr/asm.rs | 2 +- sway-parse/src/expr/mod.rs | 6 +- sway-parse/src/item/mod.rs | 2 +- sway-parse/src/module.rs | 2 +- sway-parse/src/parse.rs | 4 +- sway-parse/src/punctuated.rs | 2 +- sway-parse/src/ty/mod.rs | 2 +- sway-types/src/integer_bits.rs | 2 +- swayfmt/src/config/manifest.rs | 2 +- swayfmt/src/formatter/mod.rs | 2 +- swayfmt/src/formatter/shape.rs | 2 +- swayfmt/src/items/item_abi.rs | 4 +- swayfmt/src/items/item_enum/mod.rs | 4 +- swayfmt/src/items/item_fn/mod.rs | 8 +- swayfmt/src/items/item_impl/mod.rs | 8 +- swayfmt/src/items/item_storage/mod.rs | 4 +- swayfmt/src/items/item_trait.rs | 4 +- swayfmt/src/items/item_use/mod.rs | 2 +- test/src/e2e_vm_tests/harness.rs | 13 +- test/src/e2e_vm_tests/mod.rs | 12 +- 90 files changed, 400 insertions(+), 427 deletions(-) diff --git a/forc-pkg/src/lock.rs b/forc-pkg/src/lock.rs index 2c00a399d75..eb04e8b6905 100644 --- a/forc-pkg/src/lock.rs +++ b/forc-pkg/src/lock.rs @@ -266,7 +266,7 @@ fn pkg_name_disambiguated<'a>(name: &'a str, source: &'a str, disambiguate: bool } fn pkg_unique_string(name: &str, source: &str) -> String { - format!("{} {}", name, source) + format!("{name} {source}") } fn pkg_dep_line( @@ -282,7 +282,7 @@ fn pkg_dep_line( // Prefix the dependency name if it differs from the package name. let pkg_string = match dep_name { None => pkg_string.into_owned(), - Some(dep_name) => format!("({}) {}", dep_name, pkg_string), + Some(dep_name) => format!("({dep_name}) {pkg_string}"), }; // Append the salt if dep_kind is DepKind::Contract. match dep_kind { @@ -291,7 +291,7 @@ fn pkg_dep_line( if *salt == fuel_tx::Salt::zeroed() { pkg_string } else { - format!("{} ({})", pkg_string, salt) + format!("{pkg_string} ({salt})") } } } @@ -350,7 +350,7 @@ where for pkg in removed { if !member_names.contains(&pkg.name) { let name = name_or_git_unique_string(pkg); - println_red(&format!(" Removing {}", name)); + println_red(&format!(" Removing {name}")); } } } @@ -362,7 +362,7 @@ where for pkg in removed { if !member_names.contains(&pkg.name) { let name = name_or_git_unique_string(pkg); - println_green(&format!(" Adding {}", name)); + println_green(&format!(" Adding {name}")); } } } diff --git a/forc-pkg/src/manifest.rs b/forc-pkg/src/manifest.rs index 753d3312c5a..ca9ead4e685 100644 --- a/forc-pkg/src/manifest.rs +++ b/forc-pkg/src/manifest.rs @@ -414,7 +414,7 @@ impl PackageManifest { .map_err(|e| anyhow!("failed to read manifest at {:?}: {}", path, e))?; let toml_de = &mut toml::de::Deserializer::new(&manifest_str); let mut manifest: Self = serde_ignored::deserialize(toml_de, |path| { - let warning = format!(" WARNING! unused manifest key: {}", path); + let warning = format!(" WARNING! unused manifest key: {path}"); warnings.push(warning); }) .map_err(|e| anyhow!("failed to parse manifest: {}.", e))?; @@ -810,7 +810,7 @@ impl WorkspaceManifest { .map_err(|e| anyhow!("failed to read manifest at {:?}: {}", path, e))?; let toml_de = &mut toml::de::Deserializer::new(&manifest_str); let manifest: Self = serde_ignored::deserialize(toml_de, |path| { - let warning = format!(" WARNING! unused manifest key: {}", path); + let warning = format!(" WARNING! unused manifest key: {path}"); warnings.push(warning); }) .map_err(|e| anyhow!("failed to parse manifest: {}.", e))?; @@ -850,7 +850,7 @@ impl WorkspaceManifest { let duplicate_paths = pkg_name_to_paths .get(pkg_name) .expect("missing duplicate paths"); - format!("{}: {:#?}", pkg_name, duplicate_paths) + format!("{pkg_name}: {duplicate_paths:#?}") }) .collect::>(); diff --git a/forc-pkg/src/pkg.rs b/forc-pkg/src/pkg.rs index b4161e095f6..e93d2e0242c 100644 --- a/forc-pkg/src/pkg.rs +++ b/forc-pkg/src/pkg.rs @@ -437,7 +437,7 @@ impl BuiltPackage { self.write_bytecode(&bin_path)?; - let json_abi_program_stem = format!("{}-abi", pkg_name); + let json_abi_program_stem = format!("{pkg_name}-abi"); let json_abi_program_path = output_dir .join(json_abi_program_stem) .with_extension("json"); @@ -471,7 +471,7 @@ impl BuiltPackage { match self.tree_type { TreeType::Contract => { // For contracts, emit a JSON file with all the initialized storage slots. - let json_storage_slots_stem = format!("{}-storage_slots", pkg_name); + let json_storage_slots_stem = format!("{pkg_name}-storage_slots"); let json_storage_slots_path = output_dir .join(json_storage_slots_stem) .with_extension("json"); @@ -1068,7 +1068,7 @@ impl GitReference { pub fn resolve(&self, repo: &git2::Repository) -> Result { // Find the commit associated with this tag. fn resolve_tag(repo: &git2::Repository, tag: &str) -> Result { - let refname = format!("refs/remotes/{}/tags/{}", DEFAULT_REMOTE_NAME, tag); + let refname = format!("refs/remotes/{DEFAULT_REMOTE_NAME}/tags/{tag}"); let id = repo.refname_to_id(&refname)?; let obj = repo.find_object(id, None)?; let obj = obj.peel(git2::ObjectType::Commit)?; @@ -1077,10 +1077,10 @@ impl GitReference { // Resolve to the target for the given branch. fn resolve_branch(repo: &git2::Repository, branch: &str) -> Result { - let name = format!("{}/{}", DEFAULT_REMOTE_NAME, branch); + let name = format!("{DEFAULT_REMOTE_NAME}/{branch}"); let b = repo .find_branch(&name, git2::BranchType::Remote) - .with_context(|| format!("failed to find branch `{}`", branch))?; + .with_context(|| format!("failed to find branch `{branch}`"))?; b.get() .target() .ok_or_else(|| anyhow::format_err!("branch `{}` did not have a target", branch)) @@ -1089,7 +1089,7 @@ impl GitReference { // Use the HEAD commit when default branch is specified. fn resolve_default_branch(repo: &git2::Repository) -> Result { let head_id = - repo.refname_to_id(&format!("refs/remotes/{}/HEAD", DEFAULT_REMOTE_NAME))?; + repo.refname_to_id(&format!("refs/remotes/{DEFAULT_REMOTE_NAME}/HEAD"))?; let head = repo.find_object(head_id, None)?; Ok(head.peel(git2::ObjectType::Commit)?.id()) } @@ -1105,7 +1105,7 @@ impl GitReference { match self { GitReference::Tag(s) => { - resolve_tag(repo, s).with_context(|| format!("failed to find tag `{}`", s)) + resolve_tag(repo, s).with_context(|| format!("failed to find tag `{s}`")) } GitReference::Branch(s) => resolve_branch(repo, s), GitReference::DefaultBranch => resolve_default_branch(repo), @@ -1184,8 +1184,8 @@ impl fmt::Display for SourceGitPinned { impl fmt::Display for GitReference { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - GitReference::Branch(ref s) => write!(f, "branch={}", s), - GitReference::Tag(ref s) => write!(f, "tag={}", s), + GitReference::Branch(ref s) => write!(f, "branch={s}"), + GitReference::Tag(ref s) => write!(f, "tag={s}"), GitReference::Rev(ref _s) => write!(f, "rev"), GitReference::DefaultBranch => write!(f, "default-branch"), } @@ -1667,7 +1667,7 @@ fn fetch_deps( /// The name to use for a package's git repository under the user's forc directory. fn git_repo_dir_name(name: &str, repo: &Url) -> String { let repo_url_hash = hash_url(repo); - format!("{}-{:x}", name, repo_url_hash) + format!("{name}-{repo_url_hash:x}") } fn hash_url(url: &Url) -> u64 { @@ -1702,32 +1702,29 @@ fn git_ref_to_refspecs(reference: &GitReference) -> (Vec, bool) { match reference { GitReference::Branch(s) => { refspecs.push(format!( - "+refs/heads/{1}:refs/remotes/{0}/{1}", - DEFAULT_REMOTE_NAME, s + "+refs/heads/{s}:refs/remotes/{DEFAULT_REMOTE_NAME}/{s}" )); } GitReference::Tag(s) => { refspecs.push(format!( - "+refs/tags/{1}:refs/remotes/{0}/tags/{1}", - DEFAULT_REMOTE_NAME, s + "+refs/tags/{s}:refs/remotes/{DEFAULT_REMOTE_NAME}/tags/{s}" )); } GitReference::Rev(s) => { if s.starts_with("refs/") { - refspecs.push(format!("+{0}:{0}", s)); + refspecs.push(format!("+{s}:{s}")); } else { // We can't fetch the commit directly, so we fetch all branches and tags in order // to find it. refspecs.push(format!( - "+refs/heads/*:refs/remotes/{}/*", - DEFAULT_REMOTE_NAME + "+refs/heads/*:refs/remotes/{DEFAULT_REMOTE_NAME}/*" )); - refspecs.push(format!("+HEAD:refs/remotes/{}/HEAD", DEFAULT_REMOTE_NAME)); + refspecs.push(format!("+HEAD:refs/remotes/{DEFAULT_REMOTE_NAME}/HEAD")); tags = true; } } GitReference::DefaultBranch => { - refspecs.push(format!("+HEAD:refs/remotes/{}/HEAD", DEFAULT_REMOTE_NAME)); + refspecs.push(format!("+HEAD:refs/remotes/{DEFAULT_REMOTE_NAME}/HEAD")); } } (refspecs, tags) @@ -1785,7 +1782,7 @@ pub fn pin_git(fetch_id: u64, name: &str, source: SourceGit) -> Result PathBuf { path.hash(&mut hasher); let hash = hasher.finish(); let file_name = match path.file_stem().and_then(|s| s.to_str()) { - None => format!("{:X}", hash), - Some(stem) => format!("{:X}-{}", hash, stem), + None => format!("{hash:X}"), + Some(stem) => format!("{hash:X}-{stem}"), }; user_forc_directory() @@ -3293,10 +3290,10 @@ pub fn manifest_file_missing(dir: &Path) -> anyhow::Error { pub fn parsing_failed(project_name: &str, errors: Vec) -> anyhow::Error { let error = errors .iter() - .map(|e| format!("{}", e)) + .map(|e| format!("{e}")) .collect::>() .join("\n"); - let message = format!("Parsing {} failed: \n{}", project_name, error); + let message = format!("Parsing {project_name} failed: \n{error}"); Error::msg(message) } @@ -3306,15 +3303,12 @@ pub fn wrong_program_type( expected_types: Vec, parse_type: TreeType, ) -> anyhow::Error { - let message = format!( - "{} is not a '{:?}' it is a '{:?}'", - project_name, expected_types, parse_type - ); + let message = format!("{project_name} is not a '{expected_types:?}' it is a '{parse_type:?}'"); Error::msg(message) } /// Format an error message if a given URL fails to produce a working node. pub fn fuel_core_not_running(node_url: &str) -> anyhow::Error { - let message = format!("could not get a response from node at the URL {}. Start a node with `fuel-core`. See https://github.com/FuelLabs/fuel-core#running for more information", node_url); + let message = format!("could not get a response from node at the URL {node_url}. Start a node with `fuel-core`. See https://github.com/FuelLabs/fuel-core#running for more information"); Error::msg(message) } diff --git a/forc-plugins/forc-client/src/ops/tx_util.rs b/forc-plugins/forc-client/src/ops/tx_util.rs index d2a61405a8b..47233c09971 100644 --- a/forc-plugins/forc-client/src/ops/tx_util.rs +++ b/forc-plugins/forc-client/src/ops/tx_util.rs @@ -25,7 +25,7 @@ fn prompt_address() -> Result { } fn prompt_signature(tx_id: fuel_tx::Bytes32) -> Result { - println!("Transaction id to sign: {}", tx_id); + println!("Transaction id to sign: {tx_id}"); print!("Please provide the signature:"); std::io::stdout().flush()?; let mut buf = String::new(); diff --git a/forc-plugins/forc-doc/src/doc.rs b/forc-plugins/forc-doc/src/doc.rs index 0a80e04f9ce..c89c9cc5e76 100644 --- a/forc-plugins/forc-doc/src/doc.rs +++ b/forc-plugins/forc-doc/src/doc.rs @@ -208,7 +208,7 @@ impl ModuleInfo { let prefix = self.to_path_literal_prefix(location); match prefix.is_empty() { true => item_name.to_owned(), - false => format!("{}::{}", prefix, item_name), + false => format!("{prefix}::{item_name}"), } } /// Create a path literal prefix from the module prefixes. diff --git a/forc-plugins/forc-doc/src/render.rs b/forc-plugins/forc-doc/src/render.rs index 19f71e414eb..1c148b997fa 100644 --- a/forc-plugins/forc-doc/src/render.rs +++ b/forc-plugins/forc-doc/src/render.rs @@ -408,7 +408,7 @@ impl Renderable for ItemBody { span(class="in-band") { // TODO: pass the decl ty info or match // for uppercase naming like: "Enum" - : format!("{} ", friendly_name); + : format!("{friendly_name} "); // TODO: add qualified path anchors a(class=&decl_ty, href=IDENTITY) { : item_name.as_str(); @@ -555,7 +555,7 @@ fn context_section<'title, S: Renderable + 'static>( box_html! { h2(id=&lct, class=format!("{} small-section-header", &lct)) { : title.as_str(); - a(class="anchor", href=format!("{}{}", IDENTITY, lct)); + a(class="anchor", href=format!("{IDENTITY}{lct}")); } @ for item in list { // TODO: Check for visibility of the field itself @@ -568,7 +568,7 @@ impl Renderable for TyStructField { let struct_field_id = format!("structfield.{}", self.name.as_str()); box_html! { span(id=&struct_field_id, class="structfield small-section-header") { - a(class="anchor field", href=format!("{}{}", IDENTITY, struct_field_id)); + a(class="anchor field", href=format!("{IDENTITY}{struct_field_id}")); code { : format!("{}: ", self.name.as_str()); // TODO: Add links to types based on visibility @@ -588,7 +588,7 @@ impl Renderable for TyStorageField { let storage_field_id = format!("storagefield.{}", self.name.as_str()); box_html! { span(id=&storage_field_id, class="storagefield small-section-header") { - a(class="anchor field", href=format!("{}{}", IDENTITY, storage_field_id)); + a(class="anchor field", href=format!("{IDENTITY}{storage_field_id}")); code { : format!("{}: ", self.name.as_str()); // TODO: Add links to types based on visibility @@ -608,7 +608,7 @@ impl Renderable for TyEnumVariant { let enum_variant_id = format!("variant.{}", self.name.as_str()); box_html! { h3(id=&enum_variant_id, class="variant small-section-header") { - a(class="anchor field", href=format!("{}{}", IDENTITY, enum_variant_id)); + a(class="anchor field", href=format!("{IDENTITY}{enum_variant_id}")); code { : format!("{}: ", self.name.as_str()); : self.type_span.as_str(); @@ -660,7 +660,7 @@ impl Renderable for TyTraitFn { div(id=&method_id, class="method has-srclink") { h4(class="code-header") { : "fn "; - a(class="fnname", href=format!("{}{}", IDENTITY, method_id)) { + a(class="fnname", href=format!("{IDENTITY}{method_id}")) { : self.name.as_str(); } : "("; @@ -1111,7 +1111,7 @@ impl Renderable for Sidebar { let (logo_path_to_parent, path_to_parent_or_self) = match &self.style { DocStyle::AllDoc | DocStyle::Item => (self.href_path.clone(), self.href_path.clone()), DocStyle::ProjectIndex => (IDENTITY.to_owned(), IDENTITY.to_owned()), - DocStyle::ModuleIndex => (format!("../{}", INDEX_FILENAME), IDENTITY.to_owned()), + DocStyle::ModuleIndex => (format!("../{INDEX_FILENAME}"), IDENTITY.to_owned()), }; // Unfortunately, match arms that return a closure, even if they are the same // type, are incompatible. The work around is to return a String instead, @@ -1128,7 +1128,7 @@ impl Renderable for Sidebar { div(class="block") { ul { li(class="version") { - : format!("Version {}", version); + : format!("Version {version}"); } li { a(id="all-types", href=ALL_DOC_FILENAME) { diff --git a/forc-plugins/forc-fmt/src/main.rs b/forc-plugins/forc-fmt/src/main.rs index 34f47e5f610..ac9824a593c 100644 --- a/forc-plugins/forc-fmt/src/main.rs +++ b/forc-plugins/forc-fmt/src/main.rs @@ -147,22 +147,22 @@ fn display_file_diff(file_content: &str, formatted_content: &str) -> Result<()> DiffOp::Insert(new) => { count_of_updates += 1; for n in new { - println_green(&format!("+{}", n)); + println_green(&format!("+{n}")); } } DiffOp::Remove(old) => { count_of_updates += 1; for o in old { - println_red(&format!("-{}", o)); + println_red(&format!("-{o}")); } } DiffOp::Replace(old, new) => { count_of_updates += 1; for o in old { - println_red(&format!("-{}", o)); + println_red(&format!("-{o}")); } for n in new { - println_green(&format!("+{}", n)); + println_green(&format!("+{n}")); } } } diff --git a/forc-plugins/forc-tx/src/lib.rs b/forc-plugins/forc-tx/src/lib.rs index 145a4560490..22a6affbeea 100644 --- a/forc-plugins/forc-tx/src/lib.rs +++ b/forc-plugins/forc-tx/src/lib.rs @@ -643,9 +643,8 @@ fn test_parse_mint_coin() { let asset_id = fuel_tx::AssetId::default(); let cmd = format!( r#" - forc-tx mint --tx-ptr {:X} output coin --to {address} --amount 100 --asset-id {asset_id} - "#, - tx_ptr + forc-tx mint --tx-ptr {tx_ptr:X} output coin --to {address} --amount 100 --asset-id {asset_id} + "# ); dbg!(Command::try_parse_from_args(cmd.split_whitespace().map(|s| s.to_string())).unwrap()); } @@ -677,7 +676,7 @@ fn test_parse_create_inputs_outputs() { --owner {address} --amount 100 --asset-id {asset_id} - --tx-ptr {:X} + --tx-ptr {tx_ptr:X} --witness-ix 0 --maturity 0 --predicate ./my-predicate/out/debug/my-predicate.bin @@ -687,7 +686,7 @@ fn test_parse_create_inputs_outputs() { --output-ix 1 --balance-root {balance_root} --state-root {state_root} - --tx-ptr {:X} + --tx-ptr {tx_ptr:X} --contract-id {contract_id} input message --msg-id {msg_id} @@ -721,8 +720,7 @@ fn test_parse_create_inputs_outputs() { output contract-created --contract-id {contract_id} --state-root {state_root} - "#, - tx_ptr, tx_ptr + "# ); dbg!(Command::try_parse_from_args(args.split_whitespace().map(|s| s.to_string())).unwrap()); } diff --git a/forc-plugins/forc-tx/src/main.rs b/forc-plugins/forc-tx/src/main.rs index a44d035ad70..b1a30ec0b87 100644 --- a/forc-plugins/forc-tx/src/main.rs +++ b/forc-plugins/forc-tx/src/main.rs @@ -4,7 +4,7 @@ fn main() { match cmd.output_path { None => { let string = serde_json::to_string_pretty(&tx).unwrap(); - println!("{}", string); + println!("{string}"); } Some(path) => { let file = std::fs::File::create(path).unwrap(); diff --git a/forc-util/src/lib.rs b/forc-util/src/lib.rs index aa31439b072..82917e70b82 100644 --- a/forc-util/src/lib.rs +++ b/forc-util/src/lib.rs @@ -192,7 +192,7 @@ pub fn print_on_success( } if warnings.is_empty() { - println_green_err(&format!(" Compiled {} {:?}.", type_str, proj_name)); + println_green_err(&format!(" Compiled {type_str} {proj_name:?}.")); } else { println_yellow_err(&format!( " Compiled {} {:?} with {} {}.", @@ -214,7 +214,7 @@ pub fn print_on_success_library(terse_mode: bool, proj_name: &str, warnings: &[C } if warnings.is_empty() { - println_green_err(&format!(" Compiled library {:?}.", proj_name)); + println_green_err(&format!(" Compiled library {proj_name:?}.")); } else { println_yellow_err(&format!( " Compiled library {:?} with {} {}.", @@ -252,7 +252,7 @@ fn format_err(err: &CompileError) { let mut start_pos = span.start(); let mut end_pos = span.end(); - let friendly_str = maybe_uwuify(&format!("{}", err)); + let friendly_str = maybe_uwuify(&format!("{err}")); let (snippet_title, snippet_slices) = if start_pos < end_pos { let title = Some(Annotation { label: None, diff --git a/forc/src/cli/commands/addr2line.rs b/forc/src/cli/commands/addr2line.rs index 01e660c4c46..6a7004a002b 100644 --- a/forc/src/cli/commands/addr2line.rs +++ b/forc/src/cli/commands/addr2line.rs @@ -50,7 +50,7 @@ pub(crate) fn exec(command: Command) -> Result<()> { let rr = read_range(&path, range, command.context) .map_err(|err| anyhow!("{:?}: could not read: {:?}", path, err))?; - let path_str = format!("{:?}", path); + let path_str = format!("{path:?}"); let snippet = Snippet { title: None, footer: vec![], diff --git a/forc/src/cli/commands/plugins.rs b/forc/src/cli/commands/plugins.rs index f8d1c450279..c9d238b829d 100644 --- a/forc/src/cli/commands/plugins.rs +++ b/forc/src/cli/commands/plugins.rs @@ -81,7 +81,7 @@ fn format_print_description( let description = parse_description_for_plugin(&path); if describe { - Ok(format!(" {} \t\t{}", display, description)) + Ok(format!(" {display} \t\t{description}")) } else { Ok(display) } diff --git a/forc/src/utils/program_type.rs b/forc/src/utils/program_type.rs index 44245d05551..b1d1bb0f0ed 100644 --- a/forc/src/utils/program_type.rs +++ b/forc/src/utils/program_type.rs @@ -15,6 +15,6 @@ impl std::fmt::Display for ProgramType { Predicate => "predicate", Library => "library", }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/scripts/examples-checker/src/main.rs b/scripts/examples-checker/src/main.rs index bc820fddfa6..123619c9d1b 100644 --- a/scripts/examples-checker/src/main.rs +++ b/scripts/examples-checker/src/main.rs @@ -95,7 +95,7 @@ fn run_forc_fmt(path: &Path) -> bool { } fn print_summary(summary: &[(PathBuf, bool)], command_kind: CommandKind) -> Result<()> { - println!("\nSummary for command {}:", command_kind); + println!("\nSummary for command {command_kind}:"); let mut successes = 0; for (path, success) in summary { let (checkmark, status) = if *success { @@ -115,10 +115,7 @@ fn print_summary(summary: &[(PathBuf, bool)], command_kind: CommandKind) -> Resu "successes" }; let failures_str = if failures == 1 { "failure" } else { "failures" }; - println!( - "{} {}, {} {}", - successes, successes_str, failures, failures_str - ); + println!("{successes} {successes_str}, {failures} {failures_str}"); if failures > 0 { return Err(anyhow!("{} failed to run for some examples", command_kind)); diff --git a/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs b/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs index b7350bafd52..e79f26fb9cc 100644 --- a/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs +++ b/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs @@ -25,7 +25,7 @@ fn main() { if let Some(sub_args) = matches.subcommand_matches("supports") { handle_supports(&preprocessor, sub_args); } else if let Err(e) = handle_preprocessing(&preprocessor) { - eprintln!("{}", e); + eprintln!("{e}"); process::exit(1); } } diff --git a/scripts/mdbook-forc-documenter/src/formatter.rs b/scripts/mdbook-forc-documenter/src/formatter.rs index 882416309ac..03ab5ecd437 100644 --- a/scripts/mdbook-forc-documenter/src/formatter.rs +++ b/scripts/mdbook-forc-documenter/src/formatter.rs @@ -153,7 +153,7 @@ fn format_option(option: &str) -> String { pub fn format_index_entry(forc_command_str: &str) -> String { let command_name = forc_command_str; let command_link = forc_command_str.replace(' ', "_"); - format!("- [{}](./{}.md)\n", command_name, command_link) + format!("- [{command_name}](./{command_link}.md)\n") } #[cfg(test)] diff --git a/scripts/mdbook-forc-documenter/src/lib.rs b/scripts/mdbook-forc-documenter/src/lib.rs index 3381853e87e..2ee8408762f 100644 --- a/scripts/mdbook-forc-documenter/src/lib.rs +++ b/scripts/mdbook-forc-documenter/src/lib.rs @@ -117,7 +117,7 @@ impl Preprocessor for ForcDocumenter { } else { if !error_message.is_empty() { eprintln!("Warning:"); - eprintln!("{}", error_message); + eprintln!("{error_message}"); eprintln!("The book built successfully - if the changes above were intended or if you are editing pages unrelated to Forc, you may ignore this message."); } Ok(book) @@ -144,8 +144,7 @@ fn missing_entries_msg(missing: &[String]) -> String { .collect::(); let missing_entries: String = missing.iter().map(|c| format_index_entry(c)).collect(); - format!("\nSome entries were missing from SUMMARY.md:\n\n{}\n\nTo fix this, add the above entries under the Commands or Plugins chapter in SUMMARY.md, like so:\n\n{}\n", - missing_commands, missing_entries) + format!("\nSome entries were missing from SUMMARY.md:\n\n{missing_commands}\n\nTo fix this, add the above entries under the Commands or Plugins chapter in SUMMARY.md, like so:\n\n{missing_entries}\n") } fn dangling_chapters_msg(commands: &[String]) -> String { diff --git a/sway-ast/src/intrinsics.rs b/sway-ast/src/intrinsics.rs index 22639dca598..3524e5c76b1 100644 --- a/sway-ast/src/intrinsics.rs +++ b/sway-ast/src/intrinsics.rs @@ -48,7 +48,7 @@ impl fmt::Display for Intrinsic { Intrinsic::PtrSub => "ptr_sub", Intrinsic::Smo => "smo", }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs index aef5b0d5212..71becd95639 100644 --- a/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs @@ -212,7 +212,7 @@ impl fmt::Display for AbstractInstructionSet { ".program:\n{}", self.ops .iter() - .map(|x| format!("{}", x)) + .map(|x| format!("{x}")) .collect::>() .join("\n") ) diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index b0d45e9de48..f5b6f63daba 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs @@ -116,7 +116,7 @@ impl AllocatedAbstractInstructionSet { ); new_ops.push(AllocatedAbstractOp { opcode: Either::Left(store_op), - comment: format!("save {}", reg), + comment: format!("save {reg}"), owning_span: None, }); }) @@ -149,7 +149,7 @@ impl AllocatedAbstractInstructionSet { ); new_ops.push(AllocatedAbstractOp { opcode: Either::Left(load_op), - comment: format!("restore {}", reg), + comment: format!("restore {reg}"), owning_span: None, }); }); diff --git a/sway-core/src/asm_generation/fuel/data_section.rs b/sway-core/src/asm_generation/fuel/data_section.rs index ebd97705f58..ff079dfa33f 100644 --- a/sway-core/src/asm_generation/fuel/data_section.rs +++ b/sway-core/src/asm_generation/fuel/data_section.rs @@ -287,6 +287,6 @@ impl fmt::Display for DataSection { )?; } - write!(f, ".data:\n{}", data_buf) + write!(f, ".data:\n{data_buf}") } } diff --git a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs index 634f2605d17..0fb0a629804 100644 --- a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs +++ b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs @@ -831,7 +831,7 @@ impl<'ir> FuelAsmBuilder<'ir> { "extract_value @ {}", indices .iter() - .map(|idx| format!("{}", idx)) + .map(|idx| format!("{idx}")) .collect::>() .join(",") ), @@ -850,7 +850,7 @@ impl<'ir> FuelAsmBuilder<'ir> { "extract_value @ {}", indices .iter() - .map(|idx| format!("{}", idx)) + .map(|idx| format!("{idx}")) .collect::>() .join(",") ), @@ -1118,7 +1118,7 @@ impl<'ir> FuelAsmBuilder<'ir> { let indices_str = indices .iter() - .map(|idx| format!("{}", idx)) + .map(|idx| format!("{idx}")) .collect::>() .join(","); @@ -1143,7 +1143,7 @@ impl<'ir> FuelAsmBuilder<'ir> { insert_reg, VirtualImmediate12 { value: 0 }, )), - comment: format!("insert_value @ {}", indices_str), + comment: format!("insert_value @ {indices_str}"), owning_span, }); } else { @@ -1155,7 +1155,7 @@ impl<'ir> FuelAsmBuilder<'ir> { value: insert_offs as u16, }, )), - comment: format!("insert_value @ {}", indices_str), + comment: format!("insert_value @ {indices_str}"), owning_span, }); } @@ -1172,7 +1172,7 @@ impl<'ir> FuelAsmBuilder<'ir> { value: (insert_offs * 8) as u16, }, )), - comment: format!("get struct field(s) {} offset", indices_str), + comment: format!("get struct field(s) {indices_str} offset"), owning_span: owning_span.clone(), }); } diff --git a/sway-core/src/asm_generation/fuel/functions.rs b/sway-core/src/asm_generation/fuel/functions.rs index d93a35b3d9e..974a81be15b 100644 --- a/sway-core/src/asm_generation/fuel/functions.rs +++ b/sway-core/src/asm_generation/fuel/functions.rs @@ -356,7 +356,7 @@ impl<'ir> FuelAsmBuilder<'ir> { args_base_reg.clone(), offs_reg.clone(), )), - comment: format!("get offset for arg {}", name), + comment: format!("get offset for arg {name}"), owning_span: None, }); self.cur_bytecode.push(Op { @@ -365,7 +365,7 @@ impl<'ir> FuelAsmBuilder<'ir> { offs_reg, VirtualImmediate12 { value: 0 }, )), - comment: format!("get arg {}", name), + comment: format!("get arg {name}"), owning_span: None, }); } else { @@ -377,7 +377,7 @@ impl<'ir> FuelAsmBuilder<'ir> { value: arg_word_offset as u16, }, )), - comment: format!("get arg {}", name), + comment: format!("get arg {name}"), owning_span: None, }); } @@ -390,7 +390,7 @@ impl<'ir> FuelAsmBuilder<'ir> { args_base_reg.clone(), offs_reg, )), - comment: format!("get offset or arg {}", name), + comment: format!("get offset or arg {name}"), owning_span: None, }); } else { @@ -402,7 +402,7 @@ impl<'ir> FuelAsmBuilder<'ir> { value: (arg_word_offset * 8) as u16, }, )), - comment: format!("get address for arg {}", name), + comment: format!("get address for arg {name}"), owning_span: None, }); } @@ -652,7 +652,7 @@ impl<'ir> FuelAsmBuilder<'ir> { opcode: Either::Left(VirtualOp::CFEI(VirtualImmediate24 { value: locals_size as u32, })), - comment: format!("allocate {} bytes for locals", locals_size), + comment: format!("allocate {locals_size} bytes for locals"), owning_span: None, }); } @@ -672,7 +672,7 @@ impl<'ir> FuelAsmBuilder<'ir> { opcode: Either::Left(VirtualOp::CFSI(VirtualImmediate24 { value: locals_size as u32, })), - comment: format!("free {} bytes for locals", locals_size), + comment: format!("free {locals_size} bytes for locals"), owning_span: None, }); } diff --git a/sway-core/src/asm_generation/instruction_set.rs b/sway-core/src/asm_generation/instruction_set.rs index eaedb5150c4..c96c3f69df0 100644 --- a/sway-core/src/asm_generation/instruction_set.rs +++ b/sway-core/src/asm_generation/instruction_set.rs @@ -16,12 +16,12 @@ impl fmt::Display for InstructionSet { match self { InstructionSet::Fuel { ops } => ops .iter() - .map(|x| format!("{}", x)) + .map(|x| format!("{x}")) .collect::>() .join("\n"), InstructionSet::Evm { ops } => ops .iter() - .map(|x| format!("{}", x)) + .map(|x| format!("{x}")) .collect::>() .join("\n"), } diff --git a/sway-core/src/asm_generation/programs/final.rs b/sway-core/src/asm_generation/programs/final.rs index 38476ad8f36..2feee8db3ff 100644 --- a/sway-core/src/asm_generation/programs/final.rs +++ b/sway-core/src/asm_generation/programs/final.rs @@ -48,8 +48,8 @@ impl std::fmt::Display for FinalProgram { match self { FinalProgram::Fuel { data_section, ops, .. - } => write!(f, "{:?}\n{}", ops, data_section), - FinalProgram::Evm { ops, .. } => write!(f, "{:?}", ops), + } => write!(f, "{ops:?}\n{data_section}"), + FinalProgram::Evm { ops, .. } => write!(f, "{ops:?}"), } } } diff --git a/sway-core/src/asm_lang/allocated_ops.rs b/sway-core/src/asm_lang/allocated_ops.rs index 3131f122e0e..323e56e3f58 100644 --- a/sway-core/src/asm_lang/allocated_ops.rs +++ b/sway-core/src/asm_lang/allocated_ops.rs @@ -34,9 +34,9 @@ pub enum AllocatedRegister { impl fmt::Display for AllocatedRegister { fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - AllocatedRegister::Allocated(name) => write!(fmtr, "$r{}", name), + AllocatedRegister::Allocated(name) => write!(fmtr, "$r{name}"), AllocatedRegister::Constant(name) => { - write!(fmtr, "{}", name) + write!(fmtr, "{name}") } } } @@ -317,95 +317,95 @@ impl fmt::Display for AllocatedOpcode { use AllocatedOpcode::*; match self { /* Arithmetic/Logic (ALU) Instructions */ - ADD(a, b, c) => write!(fmtr, "add {} {} {}", a, b, c), - ADDI(a, b, c) => write!(fmtr, "addi {} {} {}", a, b, c), - AND(a, b, c) => write!(fmtr, "and {} {} {}", a, b, c), - ANDI(a, b, c) => write!(fmtr, "andi {} {} {}", a, b, c), - DIV(a, b, c) => write!(fmtr, "div {} {} {}", a, b, c), - DIVI(a, b, c) => write!(fmtr, "divi {} {} {}", a, b, c), - EQ(a, b, c) => write!(fmtr, "eq {} {} {}", a, b, c), - EXP(a, b, c) => write!(fmtr, "exp {} {} {}", a, b, c), - EXPI(a, b, c) => write!(fmtr, "expi {} {} {}", a, b, c), - GT(a, b, c) => write!(fmtr, "gt {} {} {}", a, b, c), - LT(a, b, c) => write!(fmtr, "lt {} {} {}", a, b, c), - MLOG(a, b, c) => write!(fmtr, "mlog {} {} {}", a, b, c), - MOD(a, b, c) => write!(fmtr, "mod {} {} {}", a, b, c), - MODI(a, b, c) => write!(fmtr, "modi {} {} {}", a, b, c), - MOVE(a, b) => write!(fmtr, "move {} {}", a, b), - MOVI(a, b) => write!(fmtr, "movi {} {}", a, b), - MROO(a, b, c) => write!(fmtr, "mroo {} {} {}", a, b, c), - MUL(a, b, c) => write!(fmtr, "mul {} {} {}", a, b, c), - MULI(a, b, c) => write!(fmtr, "muli {} {} {}", a, b, c), + ADD(a, b, c) => write!(fmtr, "add {a} {b} {c}"), + ADDI(a, b, c) => write!(fmtr, "addi {a} {b} {c}"), + AND(a, b, c) => write!(fmtr, "and {a} {b} {c}"), + ANDI(a, b, c) => write!(fmtr, "andi {a} {b} {c}"), + DIV(a, b, c) => write!(fmtr, "div {a} {b} {c}"), + DIVI(a, b, c) => write!(fmtr, "divi {a} {b} {c}"), + EQ(a, b, c) => write!(fmtr, "eq {a} {b} {c}"), + EXP(a, b, c) => write!(fmtr, "exp {a} {b} {c}"), + EXPI(a, b, c) => write!(fmtr, "expi {a} {b} {c}"), + GT(a, b, c) => write!(fmtr, "gt {a} {b} {c}"), + LT(a, b, c) => write!(fmtr, "lt {a} {b} {c}"), + MLOG(a, b, c) => write!(fmtr, "mlog {a} {b} {c}"), + MOD(a, b, c) => write!(fmtr, "mod {a} {b} {c}"), + MODI(a, b, c) => write!(fmtr, "modi {a} {b} {c}"), + MOVE(a, b) => write!(fmtr, "move {a} {b}"), + MOVI(a, b) => write!(fmtr, "movi {a} {b}"), + MROO(a, b, c) => write!(fmtr, "mroo {a} {b} {c}"), + MUL(a, b, c) => write!(fmtr, "mul {a} {b} {c}"), + MULI(a, b, c) => write!(fmtr, "muli {a} {b} {c}"), NOOP => write!(fmtr, "noop"), - NOT(a, b) => write!(fmtr, "not {} {}", a, b), - OR(a, b, c) => write!(fmtr, "or {} {} {}", a, b, c), - ORI(a, b, c) => write!(fmtr, "ori {} {} {}", a, b, c), - SLL(a, b, c) => write!(fmtr, "sll {} {} {}", a, b, c), - SLLI(a, b, c) => write!(fmtr, "slli {} {} {}", a, b, c), - SRL(a, b, c) => write!(fmtr, "srl {} {} {}", a, b, c), - SRLI(a, b, c) => write!(fmtr, "srli {} {} {}", a, b, c), - SUB(a, b, c) => write!(fmtr, "sub {} {} {}", a, b, c), - SUBI(a, b, c) => write!(fmtr, "subi {} {} {}", a, b, c), - XOR(a, b, c) => write!(fmtr, "xor {} {} {}", a, b, c), - XORI(a, b, c) => write!(fmtr, "xori {} {} {}", a, b, c), + NOT(a, b) => write!(fmtr, "not {a} {b}"), + OR(a, b, c) => write!(fmtr, "or {a} {b} {c}"), + ORI(a, b, c) => write!(fmtr, "ori {a} {b} {c}"), + SLL(a, b, c) => write!(fmtr, "sll {a} {b} {c}"), + SLLI(a, b, c) => write!(fmtr, "slli {a} {b} {c}"), + SRL(a, b, c) => write!(fmtr, "srl {a} {b} {c}"), + SRLI(a, b, c) => write!(fmtr, "srli {a} {b} {c}"), + SUB(a, b, c) => write!(fmtr, "sub {a} {b} {c}"), + SUBI(a, b, c) => write!(fmtr, "subi {a} {b} {c}"), + XOR(a, b, c) => write!(fmtr, "xor {a} {b} {c}"), + XORI(a, b, c) => write!(fmtr, "xori {a} {b} {c}"), /* Control Flow Instructions */ - JMP(a) => write!(fmtr, "jmp {}", a), - JI(a) => write!(fmtr, "ji {}", a), + JMP(a) => write!(fmtr, "jmp {a}"), + JI(a) => write!(fmtr, "ji {a}"), JNE(a, b, c) => write!(fmtr, "jne {a} {b} {c}"), - JNEI(a, b, c) => write!(fmtr, "jnei {} {} {}", a, b, c), - JNZI(a, b) => write!(fmtr, "jnzi {} {}", a, b), - RET(a) => write!(fmtr, "ret {}", a), + JNEI(a, b, c) => write!(fmtr, "jnei {a} {b} {c}"), + JNZI(a, b) => write!(fmtr, "jnzi {a} {b}"), + RET(a) => write!(fmtr, "ret {a}"), /* Memory Instructions */ - ALOC(a) => write!(fmtr, "aloc {}", a), - CFEI(a) => write!(fmtr, "cfei {}", a), - CFSI(a) => write!(fmtr, "cfsi {}", a), - LB(a, b, c) => write!(fmtr, "lb {} {} {}", a, b, c), - LW(a, b, c) => write!(fmtr, "lw {} {} {}", a, b, c), - MCL(a, b) => write!(fmtr, "mcl {} {}", a, b), - MCLI(a, b) => write!(fmtr, "mcli {} {}", a, b), - MCP(a, b, c) => write!(fmtr, "mcp {} {} {}", a, b, c), - MCPI(a, b, c) => write!(fmtr, "mcpi {} {} {}", a, b, c), - MEQ(a, b, c, d) => write!(fmtr, "meq {} {} {} {}", a, b, c, d), - SB(a, b, c) => write!(fmtr, "sb {} {} {}", a, b, c), - SW(a, b, c) => write!(fmtr, "sw {} {} {}", a, b, c), + ALOC(a) => write!(fmtr, "aloc {a}"), + CFEI(a) => write!(fmtr, "cfei {a}"), + CFSI(a) => write!(fmtr, "cfsi {a}"), + LB(a, b, c) => write!(fmtr, "lb {a} {b} {c}"), + LW(a, b, c) => write!(fmtr, "lw {a} {b} {c}"), + MCL(a, b) => write!(fmtr, "mcl {a} {b}"), + MCLI(a, b) => write!(fmtr, "mcli {a} {b}"), + MCP(a, b, c) => write!(fmtr, "mcp {a} {b} {c}"), + MCPI(a, b, c) => write!(fmtr, "mcpi {a} {b} {c}"), + MEQ(a, b, c, d) => write!(fmtr, "meq {a} {b} {c} {d}"), + SB(a, b, c) => write!(fmtr, "sb {a} {b} {c}"), + SW(a, b, c) => write!(fmtr, "sw {a} {b} {c}"), /* Contract Instructions */ - BAL(a, b, c) => write!(fmtr, "bal {} {} {}", a, b, c), - BHEI(a) => write!(fmtr, "bhei {}", a), - BHSH(a, b) => write!(fmtr, "bhsh {} {}", a, b), - BURN(a) => write!(fmtr, "burn {}", a), - CALL(a, b, c, d) => write!(fmtr, "call {} {} {} {}", a, b, c, d), - CB(a) => write!(fmtr, "cb {}", a), - CCP(a, b, c, d) => write!(fmtr, "ccp {} {} {} {}", a, b, c, d), - CROO(a, b) => write!(fmtr, "croo {} {}", a, b), - CSIZ(a, b) => write!(fmtr, "csiz {} {}", a, b), - LDC(a, b, c) => write!(fmtr, "ldc {} {} {}", a, b, c), - LOG(a, b, c, d) => write!(fmtr, "log {} {} {} {}", a, b, c, d), - LOGD(a, b, c, d) => write!(fmtr, "logd {} {} {} {}", a, b, c, d), - MINT(a) => write!(fmtr, "mint {}", a), - RETD(a, b) => write!(fmtr, "retd {} {}", a, b), - RVRT(a) => write!(fmtr, "rvrt {}", a), - SMO(a, b, c, d) => write!(fmtr, "smo {} {} {} {}", a, b, c, d), - SCWQ(a, b, c) => write!(fmtr, "scwq {} {} {}", a, b, c), - SRW(a, b, c) => write!(fmtr, "srw {} {} {}", a, b, c), - SRWQ(a, b, c, d) => write!(fmtr, "srwq {} {} {} {}", a, b, c, d), - SWW(a, b, c) => write!(fmtr, "sww {} {} {}", a, b, c), - SWWQ(a, b, c, d) => write!(fmtr, "swwq {} {} {} {}", a, b, c, d), - TIME(a, b) => write!(fmtr, "time {} {}", a, b), - TR(a, b, c) => write!(fmtr, "tr {} {} {}", a, b, c), - TRO(a, b, c, d) => write!(fmtr, "tro {} {} {} {}", a, b, c, d), + BAL(a, b, c) => write!(fmtr, "bal {a} {b} {c}"), + BHEI(a) => write!(fmtr, "bhei {a}"), + BHSH(a, b) => write!(fmtr, "bhsh {a} {b}"), + BURN(a) => write!(fmtr, "burn {a}"), + CALL(a, b, c, d) => write!(fmtr, "call {a} {b} {c} {d}"), + CB(a) => write!(fmtr, "cb {a}"), + CCP(a, b, c, d) => write!(fmtr, "ccp {a} {b} {c} {d}"), + CROO(a, b) => write!(fmtr, "croo {a} {b}"), + CSIZ(a, b) => write!(fmtr, "csiz {a} {b}"), + LDC(a, b, c) => write!(fmtr, "ldc {a} {b} {c}"), + LOG(a, b, c, d) => write!(fmtr, "log {a} {b} {c} {d}"), + LOGD(a, b, c, d) => write!(fmtr, "logd {a} {b} {c} {d}"), + MINT(a) => write!(fmtr, "mint {a}"), + RETD(a, b) => write!(fmtr, "retd {a} {b}"), + RVRT(a) => write!(fmtr, "rvrt {a}"), + SMO(a, b, c, d) => write!(fmtr, "smo {a} {b} {c} {d}"), + SCWQ(a, b, c) => write!(fmtr, "scwq {a} {b} {c}"), + SRW(a, b, c) => write!(fmtr, "srw {a} {b} {c}"), + SRWQ(a, b, c, d) => write!(fmtr, "srwq {a} {b} {c} {d}"), + SWW(a, b, c) => write!(fmtr, "sww {a} {b} {c}"), + SWWQ(a, b, c, d) => write!(fmtr, "swwq {a} {b} {c} {d}"), + TIME(a, b) => write!(fmtr, "time {a} {b}"), + TR(a, b, c) => write!(fmtr, "tr {a} {b} {c}"), + TRO(a, b, c, d) => write!(fmtr, "tro {a} {b} {c} {d}"), /* Cryptographic Instructions */ - ECR(a, b, c) => write!(fmtr, "ecr {} {} {}", a, b, c), - K256(a, b, c) => write!(fmtr, "k256 {} {} {}", a, b, c), - S256(a, b, c) => write!(fmtr, "s256 {} {} {}", a, b, c), + ECR(a, b, c) => write!(fmtr, "ecr {a} {b} {c}"), + K256(a, b, c) => write!(fmtr, "k256 {a} {b} {c}"), + S256(a, b, c) => write!(fmtr, "s256 {a} {b} {c}"), /* Other Instructions */ - FLAG(a) => write!(fmtr, "flag {}", a), - GM(a, b) => write!(fmtr, "gm {} {}", a, b), - GTF(a, b, c) => write!(fmtr, "gtf {} {} {}", a, b, c), + FLAG(a) => write!(fmtr, "flag {a}"), + GM(a, b) => write!(fmtr, "gm {a} {b}"), + GTF(a, b, c) => write!(fmtr, "gtf {a} {b} {c}"), /* Non-VM Instructions */ BLOB(a) => write!(fmtr, "blob {a}"), @@ -416,7 +416,7 @@ impl fmt::Display for AllocatedOpcode { ) } DataSectionRegisterLoadPlaceholder => write!(fmtr, "lw $ds $is 1"), - LWDataId(a, b) => write!(fmtr, "lw {} {}", a, b), + LWDataId(a, b) => write!(fmtr, "lw {a} {b}"), Undefined => write!(fmtr, "undefined op"), } } @@ -442,7 +442,7 @@ impl fmt::Display for AllocatedOp { write!(op_and_comment, "; {}", self.comment)?; } - write!(fmtr, "{}", op_and_comment) + write!(fmtr, "{op_and_comment}") } } diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index f7dbe797d42..572b33ce3ff 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -1408,7 +1408,7 @@ impl fmt::Display for Op { write!(op_and_comment, "; {}", self.comment)?; } - write!(fmtr, "{}", op_and_comment) + write!(fmtr, "{op_and_comment}") } } @@ -1417,95 +1417,95 @@ impl fmt::Display for VirtualOp { use VirtualOp::*; match self { /* Arithmetic/Logic (ALU) Instructions */ - ADD(a, b, c) => write!(fmtr, "add {} {} {}", a, b, c), - ADDI(a, b, c) => write!(fmtr, "addi {} {} {}", a, b, c), - AND(a, b, c) => write!(fmtr, "and {} {} {}", a, b, c), - ANDI(a, b, c) => write!(fmtr, "andi {} {} {}", a, b, c), - DIV(a, b, c) => write!(fmtr, "div {} {} {}", a, b, c), - DIVI(a, b, c) => write!(fmtr, "divi {} {} {}", a, b, c), - EQ(a, b, c) => write!(fmtr, "eq {} {} {}", a, b, c), - EXP(a, b, c) => write!(fmtr, "exp {} {} {}", a, b, c), - EXPI(a, b, c) => write!(fmtr, "expi {} {} {}", a, b, c), - GT(a, b, c) => write!(fmtr, "gt {} {} {}", a, b, c), - LT(a, b, c) => write!(fmtr, "lt {} {} {}", a, b, c), - MLOG(a, b, c) => write!(fmtr, "mlog {} {} {}", a, b, c), - MOD(a, b, c) => write!(fmtr, "mod {} {} {}", a, b, c), - MODI(a, b, c) => write!(fmtr, "modi {} {} {}", a, b, c), - MOVE(a, b) => write!(fmtr, "move {} {}", a, b), - MOVI(a, b) => write!(fmtr, "movi {} {}", a, b), - MROO(a, b, c) => write!(fmtr, "mroo {} {} {}", a, b, c), - MUL(a, b, c) => write!(fmtr, "mul {} {} {}", a, b, c), - MULI(a, b, c) => write!(fmtr, "muli {} {} {}", a, b, c), + ADD(a, b, c) => write!(fmtr, "add {a} {b} {c}"), + ADDI(a, b, c) => write!(fmtr, "addi {a} {b} {c}"), + AND(a, b, c) => write!(fmtr, "and {a} {b} {c}"), + ANDI(a, b, c) => write!(fmtr, "andi {a} {b} {c}"), + DIV(a, b, c) => write!(fmtr, "div {a} {b} {c}"), + DIVI(a, b, c) => write!(fmtr, "divi {a} {b} {c}"), + EQ(a, b, c) => write!(fmtr, "eq {a} {b} {c}"), + EXP(a, b, c) => write!(fmtr, "exp {a} {b} {c}"), + EXPI(a, b, c) => write!(fmtr, "expi {a} {b} {c}"), + GT(a, b, c) => write!(fmtr, "gt {a} {b} {c}"), + LT(a, b, c) => write!(fmtr, "lt {a} {b} {c}"), + MLOG(a, b, c) => write!(fmtr, "mlog {a} {b} {c}"), + MOD(a, b, c) => write!(fmtr, "mod {a} {b} {c}"), + MODI(a, b, c) => write!(fmtr, "modi {a} {b} {c}"), + MOVE(a, b) => write!(fmtr, "move {a} {b}"), + MOVI(a, b) => write!(fmtr, "movi {a} {b}"), + MROO(a, b, c) => write!(fmtr, "mroo {a} {b} {c}"), + MUL(a, b, c) => write!(fmtr, "mul {a} {b} {c}"), + MULI(a, b, c) => write!(fmtr, "muli {a} {b} {c}"), NOOP => Ok(()), - NOT(a, b) => write!(fmtr, "not {} {}", a, b), - OR(a, b, c) => write!(fmtr, "or {} {} {}", a, b, c), - ORI(a, b, c) => write!(fmtr, "ori {} {} {}", a, b, c), - SLL(a, b, c) => write!(fmtr, "sll {} {} {}", a, b, c), - SLLI(a, b, c) => write!(fmtr, "slli {} {} {}", a, b, c), - SRL(a, b, c) => write!(fmtr, "srl {} {} {}", a, b, c), - SRLI(a, b, c) => write!(fmtr, "srli {} {} {}", a, b, c), - SUB(a, b, c) => write!(fmtr, "sub {} {} {}", a, b, c), - SUBI(a, b, c) => write!(fmtr, "subi {} {} {}", a, b, c), - XOR(a, b, c) => write!(fmtr, "xor {} {} {}", a, b, c), - XORI(a, b, c) => write!(fmtr, "xori {} {} {}", a, b, c), + NOT(a, b) => write!(fmtr, "not {a} {b}"), + OR(a, b, c) => write!(fmtr, "or {a} {b} {c}"), + ORI(a, b, c) => write!(fmtr, "ori {a} {b} {c}"), + SLL(a, b, c) => write!(fmtr, "sll {a} {b} {c}"), + SLLI(a, b, c) => write!(fmtr, "slli {a} {b} {c}"), + SRL(a, b, c) => write!(fmtr, "srl {a} {b} {c}"), + SRLI(a, b, c) => write!(fmtr, "srli {a} {b} {c}"), + SUB(a, b, c) => write!(fmtr, "sub {a} {b} {c}"), + SUBI(a, b, c) => write!(fmtr, "subi {a} {b} {c}"), + XOR(a, b, c) => write!(fmtr, "xor {a} {b} {c}"), + XORI(a, b, c) => write!(fmtr, "xori {a} {b} {c}"), /* Control Flow Instructions */ - JMP(a) => write!(fmtr, "jmp {}", a), - JI(a) => write!(fmtr, "ji {}", a), - JNE(a, b, c) => write!(fmtr, "jne {} {} {}", a, b, c), - JNEI(a, b, c) => write!(fmtr, "jnei {} {} {}", a, b, c), - JNZI(a, b) => write!(fmtr, "jnzi {} {}", a, b), - RET(a) => write!(fmtr, "ret {}", a), + JMP(a) => write!(fmtr, "jmp {a}"), + JI(a) => write!(fmtr, "ji {a}"), + JNE(a, b, c) => write!(fmtr, "jne {a} {b} {c}"), + JNEI(a, b, c) => write!(fmtr, "jnei {a} {b} {c}"), + JNZI(a, b) => write!(fmtr, "jnzi {a} {b}"), + RET(a) => write!(fmtr, "ret {a}"), /* Memory Instructions */ - ALOC(a) => write!(fmtr, "aloc {}", a), - CFEI(a) => write!(fmtr, "cfei {}", a), - CFSI(a) => write!(fmtr, "cfsi {}", a), - LB(a, b, c) => write!(fmtr, "lb {} {} {}", a, b, c), - LW(a, b, c) => write!(fmtr, "lw {} {} {}", a, b, c), - MCL(a, b) => write!(fmtr, "mcl {} {}", a, b), - MCLI(a, b) => write!(fmtr, "mcli {} {}", a, b), - MCP(a, b, c) => write!(fmtr, "mcp {} {} {}", a, b, c), - MCPI(a, b, c) => write!(fmtr, "mcpi {} {} {}", a, b, c), - MEQ(a, b, c, d) => write!(fmtr, "meq {} {} {} {}", a, b, c, d), - SB(a, b, c) => write!(fmtr, "sb {} {} {}", a, b, c), - SW(a, b, c) => write!(fmtr, "sw {} {} {}", a, b, c), + ALOC(a) => write!(fmtr, "aloc {a}"), + CFEI(a) => write!(fmtr, "cfei {a}"), + CFSI(a) => write!(fmtr, "cfsi {a}"), + LB(a, b, c) => write!(fmtr, "lb {a} {b} {c}"), + LW(a, b, c) => write!(fmtr, "lw {a} {b} {c}"), + MCL(a, b) => write!(fmtr, "mcl {a} {b}"), + MCLI(a, b) => write!(fmtr, "mcli {a} {b}"), + MCP(a, b, c) => write!(fmtr, "mcp {a} {b} {c}"), + MCPI(a, b, c) => write!(fmtr, "mcpi {a} {b} {c}"), + MEQ(a, b, c, d) => write!(fmtr, "meq {a} {b} {c} {d}"), + SB(a, b, c) => write!(fmtr, "sb {a} {b} {c}"), + SW(a, b, c) => write!(fmtr, "sw {a} {b} {c}"), /* Contract Instructions */ - BAL(a, b, c) => write!(fmtr, "bal {} {} {}", a, b, c), - BHEI(a) => write!(fmtr, "bhei {}", a), - BHSH(a, b) => write!(fmtr, "bhsh {} {}", a, b), - BURN(a) => write!(fmtr, "burn {}", a), - CALL(a, b, c, d) => write!(fmtr, "call {} {} {} {}", a, b, c, d), - CB(a) => write!(fmtr, "cb {}", a), - CCP(a, b, c, d) => write!(fmtr, "ccp {} {} {} {}", a, b, c, d), - CROO(a, b) => write!(fmtr, "croo {} {}", a, b), - CSIZ(a, b) => write!(fmtr, "csiz {} {}", a, b), - LDC(a, b, c) => write!(fmtr, "ldc {} {} {}", a, b, c), - LOG(a, b, c, d) => write!(fmtr, "log {} {} {} {}", a, b, c, d), - LOGD(a, b, c, d) => write!(fmtr, "logd {} {} {} {}", a, b, c, d), - MINT(a) => write!(fmtr, "mint {}", a), - RETD(a, b) => write!(fmtr, "retd {} {}", a, b), - RVRT(a) => write!(fmtr, "rvrt {}", a), - SMO(a, b, c, d) => write!(fmtr, "smo {} {} {} {}", a, b, c, d), - SCWQ(a, b, c) => write!(fmtr, "scwq {} {} {}", a, b, c), - SRW(a, b, c) => write!(fmtr, "srw {} {} {}", a, b, c), - SRWQ(a, b, c, d) => write!(fmtr, "srwq {} {} {} {}", a, b, c, d), - SWW(a, b, c) => write!(fmtr, "sww {} {} {}", a, b, c), - SWWQ(a, b, c, d) => write!(fmtr, "swwq {} {} {} {}", a, b, c, d), - TIME(a, b) => write!(fmtr, "time {} {}", a, b), - TR(a, b, c) => write!(fmtr, "tr {} {} {}", a, b, c), - TRO(a, b, c, d) => write!(fmtr, "tro {} {} {} {}", a, b, c, d), + BAL(a, b, c) => write!(fmtr, "bal {a} {b} {c}"), + BHEI(a) => write!(fmtr, "bhei {a}"), + BHSH(a, b) => write!(fmtr, "bhsh {a} {b}"), + BURN(a) => write!(fmtr, "burn {a}"), + CALL(a, b, c, d) => write!(fmtr, "call {a} {b} {c} {d}"), + CB(a) => write!(fmtr, "cb {a}"), + CCP(a, b, c, d) => write!(fmtr, "ccp {a} {b} {c} {d}"), + CROO(a, b) => write!(fmtr, "croo {a} {b}"), + CSIZ(a, b) => write!(fmtr, "csiz {a} {b}"), + LDC(a, b, c) => write!(fmtr, "ldc {a} {b} {c}"), + LOG(a, b, c, d) => write!(fmtr, "log {a} {b} {c} {d}"), + LOGD(a, b, c, d) => write!(fmtr, "logd {a} {b} {c} {d}"), + MINT(a) => write!(fmtr, "mint {a}"), + RETD(a, b) => write!(fmtr, "retd {a} {b}"), + RVRT(a) => write!(fmtr, "rvrt {a}"), + SMO(a, b, c, d) => write!(fmtr, "smo {a} {b} {c} {d}"), + SCWQ(a, b, c) => write!(fmtr, "scwq {a} {b} {c}"), + SRW(a, b, c) => write!(fmtr, "srw {a} {b} {c}"), + SRWQ(a, b, c, d) => write!(fmtr, "srwq {a} {b} {c} {d}"), + SWW(a, b, c) => write!(fmtr, "sww {a} {b} {c}"), + SWWQ(a, b, c, d) => write!(fmtr, "swwq {a} {b} {c} {d}"), + TIME(a, b) => write!(fmtr, "time {a} {b}"), + TR(a, b, c) => write!(fmtr, "tr {a} {b} {c}"), + TRO(a, b, c, d) => write!(fmtr, "tro {a} {b} {c} {d}"), /* Cryptographic Instructions */ - ECR(a, b, c) => write!(fmtr, "ecr {} {} {}", a, b, c), - K256(a, b, c) => write!(fmtr, "k256 {} {} {}", a, b, c), - S256(a, b, c) => write!(fmtr, "s256 {} {} {}", a, b, c), + ECR(a, b, c) => write!(fmtr, "ecr {a} {b} {c}"), + K256(a, b, c) => write!(fmtr, "k256 {a} {b} {c}"), + S256(a, b, c) => write!(fmtr, "s256 {a} {b} {c}"), /* Other Instructions */ - FLAG(a) => write!(fmtr, "flag {}", a), - GM(a, b) => write!(fmtr, "gm {} {}", a, b), - GTF(a, b, c) => write!(fmtr, "gtf {} {} {}", a, b, c), + FLAG(a) => write!(fmtr, "flag {a}"), + GM(a, b) => write!(fmtr, "gm {a} {b}"), + GTF(a, b, c) => write!(fmtr, "gtf {a} {b} {c}"), /* Non-VM Instructions */ BLOB(a) => write!(fmtr, "blob {a}"), @@ -1513,7 +1513,7 @@ impl fmt::Display for VirtualOp { DataSectionRegisterLoadPlaceholder => { write!(fmtr, "data section register load placeholder") } - LWDataId(a, b) => write!(fmtr, "lw {} {}", a, b), + LWDataId(a, b) => write!(fmtr, "lw {a} {b}"), Undefined => write!(fmtr, "undefined op"), } } @@ -1531,7 +1531,7 @@ impl fmt::Display for AllocatedAbstractOp { write!(op_and_comment, "; {}", self.comment)?; } - write!(fmtr, "{}", op_and_comment) + write!(fmtr, "{op_and_comment}") } } @@ -1572,13 +1572,13 @@ impl fmt::Display for ControlFlowOp { fmtr, "{}", match self { - Label(lab) => format!("{}", lab), - Jump(lab) => format!("ji {}", lab), + Label(lab) => format!("{lab}"), + Jump(lab) => format!("ji {lab}"), Comment => "".into(), - JumpIfNotEq(r1, r2, lab) => format!("jnei {} {} {}", r1, r2, lab), - JumpIfNotZero(r1, lab) => format!("jnzi {} {}", r1, lab), + JumpIfNotEq(r1, r2, lab) => format!("jnei {r1} {r2} {lab}"), + JumpIfNotZero(r1, lab) => format!("jnzi {r1} {lab}"), Call(lab) => format!("fncall {lab}"), - MoveAddress(r1, lab) => format!("mova {} {}", r1, lab), + MoveAddress(r1, lab) => format!("mova {r1} {lab}"), DataSectionOffsetPlaceholder => "DATA SECTION OFFSET[0..32]\nDATA SECTION OFFSET[32..64]".into(), LoadLabel(r1, lab) => format!("lwlab {r1} {lab}"), diff --git a/sway-core/src/asm_lang/virtual_register.rs b/sway-core/src/asm_lang/virtual_register.rs index d0f0528efeb..38abb8b90c7 100644 --- a/sway-core/src/asm_lang/virtual_register.rs +++ b/sway-core/src/asm_lang/virtual_register.rs @@ -25,9 +25,9 @@ impl From for VirtualRegister { impl fmt::Display for VirtualRegister { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - VirtualRegister::Virtual(name) => write!(f, "$r{}", name), + VirtualRegister::Virtual(name) => write!(f, "$r{name}"), VirtualRegister::Constant(name) => { - write!(f, "{}", name) + write!(f, "{name}") } } } diff --git a/sway-core/src/concurrent_slab.rs b/sway-core/src/concurrent_slab.rs index 9eb53462ac1..ee6721664cf 100644 --- a/sway-core/src/concurrent_slab.rs +++ b/sway-core/src/concurrent_slab.rs @@ -50,7 +50,7 @@ where .clone() .into_iter() .enumerate() - .map(|(i, value)| format!("{:<10}\t->\t{}", i, value)) + .map(|(i, value)| format!("{i:<10}\t->\t{value}")) .collect::>(); write!(f, "{}", fmt_elems.join("\n")) } diff --git a/sway-core/src/control_flow_analysis/dead_code_analysis.rs b/sway-core/src/control_flow_analysis/dead_code_analysis.rs index 5f1fc002d70..b1cc67e40c4 100644 --- a/sway-core/src/control_flow_analysis/dead_code_analysis.rs +++ b/sway-core/src/control_flow_analysis/dead_code_analysis.rs @@ -815,11 +815,11 @@ fn depth_first_insertion_code_block<'eng: 'cfg, 'cfg>( Ok((leaves, exit_node)) } -fn get_trait_fn_node_index<'a, 'cfg>( +fn get_trait_fn_node_index<'a>( engines: Engines<'_>, function_decl_id: DeclId, expression_span: Span, - graph: &'a ControlFlowGraph<'cfg>, + graph: &'a ControlFlowGraph, ) -> Result, CompileError> { let decl_engine = engines.de(); let fn_decl = decl_engine.get_function(function_decl_id, &expression_span)?; @@ -1173,11 +1173,7 @@ fn connect_expression<'eng: 'cfg, 'cfg>( let this_ix = graph.add_node( engines, - format!( - "Struct field access: {}.{}", - resolved_type_of_parent, field_name - ) - .into(), + format!("Struct field access: {resolved_type_of_parent}.{field_name}").into(), ); for leaf in leaves { graph.add_edge(*leaf, this_ix, "".into()); @@ -1495,7 +1491,7 @@ fn connect_intrinsic_function<'eng: 'cfg, 'cfg>( exit_node: Option, tree_type: &TreeType, ) -> Result, CompileError> { - let node = graph.add_node(engines, format!("Intrinsic {}", kind).into()); + let node = graph.add_node(engines, format!("Intrinsic {kind}").into()); for leaf in leaves { graph.add_edge(*leaf, node, "".into()); } diff --git a/sway-core/src/control_flow_analysis/flow_graph/mod.rs b/sway-core/src/control_flow_analysis/flow_graph/mod.rs index 883832e7f60..5c60d37e2c6 100644 --- a/sway-core/src/control_flow_analysis/flow_graph/mod.rs +++ b/sway-core/src/control_flow_analysis/flow_graph/mod.rs @@ -129,9 +129,9 @@ impl<'cfg> std::fmt::Debug for ControlFlowGraphNode<'cfg> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let text = match self { ControlFlowGraphNode::OrganizationalDominator(s) => s.to_string(), - ControlFlowGraphNode::ProgramNode(node) => format!("{:?}", node), + ControlFlowGraphNode::ProgramNode(node) => format!("{node:?}"), ControlFlowGraphNode::EnumVariant { variant_name, .. } => { - format!("Enum variant {}", variant_name) + format!("Enum variant {variant_name}") } ControlFlowGraphNode::MethodDeclaration { method_name, diff --git a/sway-core/src/decl_engine/engine.rs b/sway-core/src/decl_engine/engine.rs index 30ee094d6ab..34c3f8fbb9b 100644 --- a/sway-core/src/decl_engine/engine.rs +++ b/sway-core/src/decl_engine/engine.rs @@ -25,7 +25,7 @@ impl fmt::Display for DeclEngine { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.slab.with_slice(|elems| { let list = ListDisplay { list: elems.iter() }; - write!(f, "DeclarationEngine {{\n{}\n}}", list) + write!(f, "DeclarationEngine {{\n{list}\n}}") }) } } diff --git a/sway-core/src/decl_engine/mapping.rs b/sway-core/src/decl_engine/mapping.rs index 878af8e1f3a..160a7ef3098 100644 --- a/sway-core/src/decl_engine/mapping.rs +++ b/sway-core/src/decl_engine/mapping.rs @@ -34,7 +34,7 @@ impl fmt::Debug for DeclMapping { "DeclMapping {{ {} }}", self.mapping .iter() - .map(|(source_type, dest_type)| { format!("{:?} -> {:?}", source_type, dest_type) }) + .map(|(source_type, dest_type)| { format!("{source_type:?} -> {dest_type:?}") }) .collect::>() .join(", ") ) diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 2d6c02be6e4..61c426a3ce2 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -1624,7 +1624,7 @@ impl<'eng> FnCompiler<'eng> { .type_engine .to_typeinfo(body.return_type, &body.span) .map_err(|ty_err| { - CompileError::InternalOwned(format!("{:?}", ty_err), body.span.clone()) + CompileError::InternalOwned(format!("{ty_err:?}"), body.span.clone()) })?, TypeInfo::ContractCaller { .. } ) { @@ -2414,7 +2414,7 @@ impl<'eng> FnCompiler<'eng> { // New name for the key let mut key_name = format!("{}{}", "key_for_", ix.to_usize()); for ix in indices { - key_name = format!("{}_{}", key_name, ix); + key_name = format!("{key_name}_{ix}"); } let alias_key_name = self.lexical_map.insert(key_name.as_str().to_owned()); @@ -2523,7 +2523,7 @@ impl<'eng> FnCompiler<'eng> { // New name for the key let mut key_name = format!("{}{}", "key_for_", ix.to_usize()); for ix in indices { - key_name = format!("{}_{}", key_name, ix); + key_name = format!("{key_name}_{ix}"); } let alias_key_name = self.lexical_map.insert(key_name.as_str().to_owned()); @@ -2646,7 +2646,7 @@ impl<'eng> FnCompiler<'eng> { // First, create a name for the value to load from or store to let mut value_name = format!("{}{}", "val_for_", ix.to_usize()); for ix in indices { - value_name = format!("{}_{}", value_name, ix); + value_name = format!("{value_name}_{ix}"); } let alias_value_name = self.lexical_map.insert(value_name.as_str().to_owned()); @@ -2684,7 +2684,7 @@ impl<'eng> FnCompiler<'eng> { // First, create a name for the value to load from or store to let mut value_name = format!("{}{}", "val_for_", ix.to_usize()); for ix in indices { - value_name = format!("{}_{}", value_name, ix); + value_name = format!("{value_name}_{ix}"); } let alias_value_name = self.lexical_map.insert(value_name.as_str().to_owned()); diff --git a/sway-core/src/ir_generation/storage.rs b/sway-core/src/ir_generation/storage.rs index df698d429b9..04f26bf519d 100644 --- a/sway-core/src/ir_generation/storage.rs +++ b/sway-core/src/ir_generation/storage.rs @@ -26,7 +26,7 @@ where sway_utils::constants::STORAGE_DOMAIN_SEPARATOR, ix.to_usize() ), - |acc, i| format!("{}_{}", acc, i), + |acc, i| format!("{acc}_{i}"), )) } diff --git a/sway-core/src/ir_generation/types.rs b/sway-core/src/ir_generation/types.rs index 308e645595b..cd025c89107 100644 --- a/sway-core/src/ir_generation/types.rs +++ b/sway-core/src/ir_generation/types.rs @@ -140,7 +140,7 @@ pub(super) fn get_indices_for_struct_access( Ok(ty_info) => ty_info, Err(error) => { return Err(CompileError::InternalOwned( - format!("type error resolving type for reassignment: {}", error), + format!("type error resolving type for reassignment: {error}"), field_kind.span(), )); } diff --git a/sway-core/src/language/call_path.rs b/sway-core/src/language/call_path.rs index 28c844c1b82..90adc6cb8b5 100644 --- a/sway-core/src/language/call_path.rs +++ b/sway-core/src/language/call_path.rs @@ -36,7 +36,7 @@ where buf.push_str("::"); } buf.push_str(&self.suffix.to_string()); - write!(f, "{}", buf) + write!(f, "{buf}") } } diff --git a/sway-core/src/language/literal.rs b/sway-core/src/language/literal.rs index 8344a115f1d..66f909c740c 100644 --- a/sway-core/src/language/literal.rs +++ b/sway-core/src/language/literal.rs @@ -99,7 +99,7 @@ impl fmt::Display for Literal { .collect::>() .join(", "), }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/sway-core/src/language/ty/expression/expression_variant.rs b/sway-core/src/language/ty/expression/expression_variant.rs index ab26d8842a6..3cfd862107f 100644 --- a/sway-core/src/language/ty/expression/expression_variant.rs +++ b/sway-core/src/language/ty/expression/expression_variant.rs @@ -705,7 +705,7 @@ impl ReplaceDecls for TyExpressionVariant { impl DisplayWithEngines for TyExpressionVariant { fn fmt(&self, f: &mut fmt::Formatter<'_>, engines: Engines<'_>) -> fmt::Result { let s = match self { - TyExpressionVariant::Literal(lit) => format!("literal {}", lit), + TyExpressionVariant::Literal(lit) => format!("literal {lit}"), TyExpressionVariant::FunctionApplication { call_path: name, .. } => { @@ -721,7 +721,7 @@ impl DisplayWithEngines for TyExpressionVariant { .map(|field| engines.help_out(field).to_string()) .collect::>() .join(", "); - format!("tuple({})", fields) + format!("tuple({fields})") } TyExpressionVariant::Array { .. } => "array".into(), TyExpressionVariant::ArrayIndex { .. } => "[..]".into(), @@ -777,7 +777,7 @@ impl DisplayWithEngines for TyExpressionVariant { format!("storage field {} access", access.storage_field_name()) } TyExpressionVariant::IntrinsicFunction(kind) => engines.help_out(kind).to_string(), - TyExpressionVariant::AbiName(n) => format!("ABI name {}", n), + TyExpressionVariant::AbiName(n) => format!("ABI name {n}"), TyExpressionVariant::EnumTag { exp } => { format!("({} as tag)", engines.help_out(exp.return_type)) } @@ -800,14 +800,14 @@ impl DisplayWithEngines for TyExpressionVariant { match index { ProjectionKind::StructField { name } => place.push_str(name.as_str()), ProjectionKind::TupleField { index, .. } => { - write!(&mut place, "{}", index).unwrap(); + write!(&mut place, "{index}").unwrap(); } ProjectionKind::ArrayIndex { index, .. } => { - write!(&mut place, "{:#?}", index).unwrap(); + write!(&mut place, "{index:#?}").unwrap(); } } } - format!("reassignment to {}", place) + format!("reassignment to {place}") } TyExpressionVariant::StorageReassignment(storage_reassignment) => { let place: String = { @@ -817,13 +817,13 @@ impl DisplayWithEngines for TyExpressionVariant { .map(|field| field.name.as_str()) .collect() }; - format!("storage reassignment to {}", place) + format!("storage reassignment to {place}") } TyExpressionVariant::Return(exp) => { format!("return {}", engines.help_out(&**exp)) } }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/sway-core/src/language/ty/expression/reassignment.rs b/sway-core/src/language/ty/expression/reassignment.rs index 5b54b7e0cb7..76c76cf489f 100644 --- a/sway-core/src/language/ty/expression/reassignment.rs +++ b/sway-core/src/language/ty/expression/reassignment.rs @@ -107,7 +107,7 @@ impl ProjectionKind { match self { ProjectionKind::StructField { name } => Cow::Borrowed(name.as_str()), ProjectionKind::TupleField { index, .. } => Cow::Owned(index.to_string()), - ProjectionKind::ArrayIndex { index, .. } => Cow::Owned(format!("{:#?}", index)), + ProjectionKind::ArrayIndex { index, .. } => Cow::Owned(format!("{index:#?}")), } } } diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs index 01bd5d6a358..4f2b888ea60 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs @@ -1053,7 +1053,7 @@ fn check_for_unconstrained_type_parameters( // create an error for all of the leftover generics for (k, v) in defined_generics.into_iter() { errors.push(CompileError::UnconstrainedGenericParameter { - ty: format!("{}", k), + ty: format!("{k}"), span: v, }); } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/patstack.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/patstack.rs index 63bf95d2485..02db91cc376 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/patstack.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/patstack.rs @@ -328,9 +328,9 @@ impl fmt::Display for PatStack { .sort() .remove_duplicates() .into_iter() - .map(|x| format!("{}", x)) + .map(|x| format!("{x}")) .join(", "); - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs index d024318f0d7..9d3311d19cd 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs @@ -685,20 +685,20 @@ impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = match self { Pattern::Wildcard => "_".to_string(), - Pattern::U8(range) => format!("{}", range), - Pattern::U16(range) => format!("{}", range), - Pattern::U32(range) => format!("{}", range), - Pattern::U64(range) => format!("{}", range), - Pattern::Numeric(range) => format!("{}", range), - Pattern::B256(n) => format!("{:#?}", n), - Pattern::Boolean(b) => format!("{}", b), + Pattern::U8(range) => format!("{range}"), + Pattern::U16(range) => format!("{range}"), + Pattern::U32(range) => format!("{range}"), + Pattern::U64(range) => format!("{range}"), + Pattern::Numeric(range) => format!("{range}"), + Pattern::B256(n) => format!("{n:#?}"), + Pattern::Boolean(b) => format!("{b}"), Pattern::String(s) => s.clone(), - Pattern::Struct(struct_pattern) => format!("{}", struct_pattern), - Pattern::Enum(enum_pattern) => format!("{}", enum_pattern), + Pattern::Struct(struct_pattern) => format!("{struct_pattern}"), + Pattern::Enum(enum_pattern) => format!("{enum_pattern}"), Pattern::Tuple(elems) => { let mut builder = String::new(); builder.push('('); - write!(builder, "{}", elems)?; + write!(builder, "{elems}")?; builder.push(')'); builder } @@ -708,7 +708,7 @@ impl fmt::Display for Pattern { .collect::>() .join(" | "), }; - write!(f, "{}", s) + write!(f, "{s}") } } @@ -786,7 +786,7 @@ impl fmt::Display for StructPattern { let mut inner_builder = String::new(); inner_builder.push_str(name); inner_builder.push_str(": "); - write!(inner_builder, "{}", field)?; + write!(inner_builder, "{field}")?; Ok(inner_builder) }) .collect::, _>>()? @@ -803,7 +803,7 @@ impl fmt::Display for StructPattern { let mut inner_builder = String::new(); inner_builder.push_str(name); inner_builder.push_str(": "); - write!(inner_builder, "{}", field)?; + write!(inner_builder, "{field}")?; Ok(inner_builder) }) .collect::, _>>()? @@ -811,7 +811,7 @@ impl fmt::Display for StructPattern { }; builder.push_str(&s); builder.push_str(" }"); - write!(f, "{}", builder) + write!(f, "{builder}") } } @@ -879,6 +879,6 @@ impl fmt::Display for EnumPattern { builder.push('('); builder.push_str(&self.value.to_string()); builder.push(')'); - write!(f, "{}", builder) + write!(f, "{builder}") } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/range.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/range.rs index 220ba3cd55d..40b985b1f0c 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/range.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/range.rs @@ -560,7 +560,7 @@ where // we bypass this problem when displaying [Range]s. if self.first == self.last { write!(builder, "{}", self.first)?; - return write!(f, "{}", builder); + return write!(f, "{builder}"); } builder.push('['); @@ -576,7 +576,7 @@ where write!(builder, "{}", self.last)?; } builder.push(']'); - write!(f, "{}", builder) + write!(f, "{builder}") } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/witness_report.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/witness_report.rs index 372e2364a7e..c01de018f18 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/witness_report.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/witness_report.rs @@ -112,8 +112,8 @@ impl fmt::Display for WitnessReport { let s = witnesses .flatten() .into_iter() - .map(|x| format!("`{}`", x)) + .map(|x| format!("`{x}`")) .join(", "); - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index e7de3436bd4..e5fd5b66aa1 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs @@ -692,7 +692,7 @@ impl ty::TyExpression { } if witness_report.has_witnesses() { errors.push(CompileError::MatchExpressionNonExhaustive { - missing_patterns: format!("{}", witness_report), + missing_patterns: format!("{witness_report}"), span, }); return err(warnings, errors); diff --git a/sway-core/src/semantic_analysis/namespace/module.rs b/sway-core/src/semantic_analysis/namespace/module.rs index f1aafb63ebd..550a034e713 100644 --- a/sway-core/src/semantic_analysis/namespace/module.rs +++ b/sway-core/src/semantic_analysis/namespace/module.rs @@ -429,14 +429,14 @@ impl<'a> std::ops::Index<&'a Path> for Module { type Output = Module; fn index(&self, path: &'a Path) -> &Self::Output { self.submodule(path) - .unwrap_or_else(|| panic!("no module for the given path {:?}", path)) + .unwrap_or_else(|| panic!("no module for the given path {path:?}")) } } impl<'a> std::ops::IndexMut<&'a Path> for Module { fn index_mut(&mut self, path: &'a Path) -> &mut Self::Output { self.submodule_mut(path) - .unwrap_or_else(|| panic!("no module for the given path {:?}", path)) + .unwrap_or_else(|| panic!("no module for the given path {path:?}")) } } diff --git a/sway-core/src/semantic_analysis/namespace/namespace.rs b/sway-core/src/semantic_analysis/namespace/namespace.rs index c6d18bab074..79c6218a2d4 100644 --- a/sway-core/src/semantic_analysis/namespace/namespace.rs +++ b/sway-core/src/semantic_analysis/namespace/namespace.rs @@ -293,7 +293,7 @@ impl Namespace { } #[allow(clippy::too_many_arguments)] - pub(crate) fn insert_trait_implementation<'a>( + pub(crate) fn insert_trait_implementation( &mut self, trait_name: CallPath, trait_type_args: Vec, @@ -301,7 +301,7 @@ impl Namespace { methods: &[DeclId], impl_span: &Span, is_impl_self: bool, - engines: Engines<'a>, + engines: Engines<'_>, ) -> CompileResult<()> { // Use trait name with full path, improves consistency between // this inserting and getting in `get_methods_for_type_and_trait_name`. diff --git a/sway-core/src/semantic_analysis/node_dependencies.rs b/sway-core/src/semantic_analysis/node_dependencies.rs index 48bcb993e88..011adc5349c 100644 --- a/sway-core/src/semantic_analysis/node_dependencies.rs +++ b/sway-core/src/semantic_analysis/node_dependencies.rs @@ -798,10 +798,10 @@ fn type_info_name(type_info: &TypeInfo) -> String { TypeInfo::Contract => "contract", TypeInfo::ErrorRecovery => "err_recov", TypeInfo::Unknown => "unknown", - TypeInfo::UnknownGeneric { name, .. } => return format!("generic {}", name), + TypeInfo::UnknownGeneric { name, .. } => return format!("generic {name}"), TypeInfo::Placeholder(_) => "_", TypeInfo::ContractCaller { abi_name, .. } => { - return format!("contract caller {}", abi_name); + return format!("contract caller {abi_name}"); } TypeInfo::Struct { .. } => "struct", TypeInfo::Enum { .. } => "enum", diff --git a/sway-core/src/type_system/engine.rs b/sway-core/src/type_system/engine.rs index 56c95c4e06f..fab1de0955f 100644 --- a/sway-core/src/type_system/engine.rs +++ b/sway-core/src/type_system/engine.rs @@ -564,7 +564,7 @@ impl TypeEngine { self.slab.with_slice(|elems| { let list = elems.iter().map(|type_info| engines.help_out(type_info)); let list = ListDisplay { list }; - write!(builder, "TypeEngine {{\n{}\n}}", list).unwrap(); + write!(builder, "TypeEngine {{\n{list}\n}}").unwrap(); }); builder } diff --git a/sway-core/src/type_system/info.rs b/sway-core/src/type_system/info.rs index b563a6f3bef..384f95edcb7 100644 --- a/sway-core/src/type_system/info.rs +++ b/sway-core/src/type_system/info.rs @@ -428,7 +428,7 @@ impl DisplayWithEngines for TypeInfo { RawUntypedPtr => "raw untyped ptr".into(), RawUntypedSlice => "raw untyped slice".into(), }; - write!(f, "{}", s) + write!(f, "{s}") } } @@ -570,13 +570,13 @@ impl TypeInfo { Contract => "contract".into(), ErrorRecovery => "unknown due to error".into(), Enum { name, .. } => { - format!("enum {}", name) + format!("enum {name}") } Struct { name, .. } => { - format!("struct {}", name) + format!("struct {name}") } ContractCaller { abi_name, .. } => { - format!("contract caller {}", abi_name) + format!("contract caller {abi_name}") } Array(elem_ty, length) => { format!("[{}; {}]", elem_ty.json_abi_str(type_engine), length.val()) diff --git a/sway-core/src/type_system/substitute.rs b/sway-core/src/type_system/substitute.rs index b532005e03d..9957312c656 100644 --- a/sway-core/src/type_system/substitute.rs +++ b/sway-core/src/type_system/substitute.rs @@ -49,7 +49,7 @@ impl fmt::Debug for TypeSubstMap { "TypeSubstMap {{ {} }}", self.mapping .iter() - .map(|(source_type, dest_type)| { format!("{:?} -> {:?}", source_type, dest_type) }) + .map(|(source_type, dest_type)| { format!("{source_type:?} -> {dest_type:?}") }) .collect::>() .join(", ") ) diff --git a/sway-error/src/error.rs b/sway-error/src/error.rs index 218c90fc552..0fda0e17b1e 100644 --- a/sway-error/src/error.rs +++ b/sway-error/src/error.rs @@ -19,8 +19,8 @@ pub enum InterfaceName { impl fmt::Display for InterfaceName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - InterfaceName::Abi(name) => write!(f, "ABI \"{}\"", name), - InterfaceName::Trait(name) => write!(f, "trait \"{}\"", name), + InterfaceName::Abi(name) => write!(f, "ABI \"{name}\""), + InterfaceName::Trait(name) => write!(f, "trait \"{name}\""), } } } diff --git a/sway-error/src/type_error.rs b/sway-error/src/type_error.rs index 1066c4ad71a..c3ed46b0750 100644 --- a/sway-error/src/type_error.rs +++ b/sway-error/src/type_error.rs @@ -8,7 +8,7 @@ pub enum TypeError { expected: {expected}\n\ found: {received}.\n\ {help}", - help = if !help_text.is_empty() { format!("help: {}", help_text) } else { String::new() } + help = if !help_text.is_empty() { format!("help: {help_text}") } else { String::new() } )] MismatchedType { expected: String, diff --git a/sway-error/src/warning.rs b/sway-error/src/warning.rs index 071d78f9650..93da602bd33 100644 --- a/sway-error/src/warning.rs +++ b/sway-error/src/warning.rs @@ -171,26 +171,21 @@ impl fmt::Display for Warning { initial_type, cast_to, } => write!(f, - "This cast, from integer type of width {} to integer type of width {}, will lose precision.", - initial_type, - cast_to + "This cast, from integer type of width {initial_type} to integer type of width {cast_to}, will lose precision." ), UnusedReturnValue { r#type } => write!( f, - "This returns a value of type {}, which is not assigned to anything and is \ - ignored.", - r#type + "This returns a value of type {type}, which is not assigned to anything and is \ + ignored." ), SimilarMethodFound { lib, module, name } => write!( f, - "A method with the same name was found for type {} in dependency \"{}::{}\". \ - Traits must be in scope in order to access their methods. ", - name, lib, module + "A method with the same name was found for type {name} in dependency \"{lib}::{module}\". \ + Traits must be in scope in order to access their methods. " ), ShadowsOtherSymbol { name } => write!( f, - "This shadows another symbol in this scope with the same name \"{}\".", - name + "This shadows another symbol in this scope with the same name \"{name}\"." ), OverridingTraitImplementation => write!( f, @@ -202,15 +197,14 @@ impl fmt::Display for Warning { DeadFunctionDeclaration => write!(f, "This function is never called."), UnreachableCode => write!(f, "This code is unreachable."), DeadEnumVariant { variant_name } => { - write!(f, "Enum variant {} is never constructed.", variant_name) + write!(f, "Enum variant {variant_name} is never constructed.") } DeadTrait => write!(f, "This trait is never implemented."), DeadMethod => write!(f, "This method is never called."), StructFieldNeverRead => write!(f, "This struct field is never accessed."), ShadowingReservedRegister { reg_name } => write!( f, - "This register declaration shadows the reserved register, \"{}\".", - reg_name + "This register declaration shadows the reserved register, \"{reg_name}\"." ), DeadStorageDeclaration => write!( f, diff --git a/sway-ir/src/analysis/dominator.rs b/sway-ir/src/analysis/dominator.rs index 783e48bf6a2..8e8b68da7fc 100644 --- a/sway-ir/src/analysis/dominator.rs +++ b/sway-ir/src/analysis/dominator.rs @@ -184,7 +184,7 @@ pub fn compute_dom_fronts(context: &Context, dom_tree: &DomTree) -> DomFronts { /// Print dominator tree in the graphviz dot format. pub fn print_dot(context: &Context, func_name: &str, dom_tree: &DomTree) -> String { - let mut res = format!("digraph {} {{\n", func_name); + let mut res = format!("digraph {func_name} {{\n"); for (b, idom) in dom_tree.iter() { if let Some(idom) = idom.parent { let _ = writeln!( @@ -201,7 +201,7 @@ pub fn print_dot(context: &Context, func_name: &str, dom_tree: &DomTree) -> Stri /// Print dominator frontiers information. pub fn print_dom_fronts(context: &Context, func_name: &str, dom_fronts: &DomFronts) -> String { - let mut res = format!("Dominance frontiers set for {}:\n", func_name); + let mut res = format!("Dominance frontiers set for {func_name}:\n"); for (b, dfs) in dom_fronts.iter() { res += &("\t".to_string() + &b.get_label(context) + ": "); for f in dfs { diff --git a/sway-ir/src/function.rs b/sway-ir/src/function.rs index 7f877ff2101..f0775a789d4 100644 --- a/sway-ir/src/function.rs +++ b/sway-ir/src/function.rs @@ -210,14 +210,14 @@ impl Function { .any(|block| context.blocks[block.0].label == hint) { let idx = self.get_next_label_idx(context); - self.get_unique_label(context, Some(format!("{}{}", hint, idx))) + self.get_unique_label(context, Some(format!("{hint}{idx}"))) } else { hint } } None => { let idx = self.get_next_label_idx(context); - self.get_unique_label(context, Some(format!("block{}", idx))) + self.get_unique_label(context, Some(format!("block{idx}"))) } } } @@ -355,7 +355,7 @@ impl Function { // one... (0..) .find_map(|n| { - let candidate = format!("{}{}", name, n); + let candidate = format!("{name}{n}"); if func.local_storage.contains_key(&candidate) { None } else { diff --git a/sway-ir/src/irtype.rs b/sway-ir/src/irtype.rs index 73fbada7770..9d2bdd525cb 100644 --- a/sway-ir/src/irtype.rs +++ b/sway-ir/src/irtype.rs @@ -138,9 +138,9 @@ impl Type { match self.get_content(context) { TypeContent::Unit => "()".into(), TypeContent::Bool => "bool".into(), - TypeContent::Uint(nbits) => format!("u{}", nbits), + TypeContent::Uint(nbits) => format!("u{nbits}"), TypeContent::B256 => "b256".into(), - TypeContent::String(n) => format!("string<{}>", n), + TypeContent::String(n) => format!("string<{n}>"), TypeContent::Array(ty, cnt) => { format!("[{}; {}]", ty.as_string(context), cnt) } diff --git a/sway-ir/src/optimize/inline.rs b/sway-ir/src/optimize/inline.rs index fca5b54d634..43208f85396 100644 --- a/sway-ir/src/optimize/inline.rs +++ b/sway-ir/src/optimize/inline.rs @@ -243,7 +243,7 @@ pub fn inline_function_call( .create_block_before( context, &post_block, - Some(format!("{}_{}", inlined_fn_name, inlined_block_label)), + Some(format!("{inlined_fn_name}_{inlined_block_label}")), ) .unwrap(); block_map.insert(inlined_block, new_block); diff --git a/sway-ir/src/printer.rs b/sway-ir/src/printer.rs index d246ad700d7..48e47685ed7 100644 --- a/sway-ir/src/printer.rs +++ b/sway-ir/src/printer.rs @@ -246,8 +246,8 @@ fn function_to_doc<'a>( .append(Doc::text_line("}")) } -fn block_to_doc<'a>( - context: &'a Context, +fn block_to_doc( + context: &Context, md_namer: &mut MetadataNamer, namer: &mut Namer, block: &Block, diff --git a/sway-ir/sway-ir-macros/src/lib.rs b/sway-ir/sway-ir-macros/src/lib.rs index c6f61e7e7c6..dd3e297dab8 100644 --- a/sway-ir/sway-ir-macros/src/lib.rs +++ b/sway-ir/sway-ir-macros/src/lib.rs @@ -48,7 +48,7 @@ pub fn derive_debug_with_context(input: TokenStream) -> TokenStream { fields, .. } = variant; - let type_variant_name = format!("{}::{}", type_name, variant_ident); + let type_variant_name = format!("{type_name}::{variant_ident}"); match fields { Fields::Named(fields_named) => { let (field_names, fmt_fields) = diff --git a/sway-ir/tests/tests.rs b/sway-ir/tests/tests.rs index 18b05159878..df67d732d35 100644 --- a/sway-ir/tests/tests.rs +++ b/sway-ir/tests/tests.rs @@ -7,7 +7,7 @@ use sway_ir::{optimize as opt, Context}; fn run_tests bool>(sub_dir: &str, opt_fn: F) { let manifest_dir = env!("CARGO_MANIFEST_DIR"); - let dir: PathBuf = format!("{}/tests/{}", manifest_dir, sub_dir).into(); + let dir: PathBuf = format!("{manifest_dir}/tests/{sub_dir}").into(); for entry in std::fs::read_dir(dir).unwrap() { let path = entry.unwrap().path(); diff --git a/sway-lsp/src/capabilities/diagnostic.rs b/sway-lsp/src/capabilities/diagnostic.rs index 923173ffed7..3cbce47baf6 100644 --- a/sway-lsp/src/capabilities/diagnostic.rs +++ b/sway-lsp/src/capabilities/diagnostic.rs @@ -14,7 +14,7 @@ fn get_error_diagnostics(errors: &[CompileError]) -> Vec { Vec::from_iter(errors.iter().map(|error| Diagnostic { range: get_range(error.span().line_col()), severity: Some(DiagnosticSeverity::ERROR), - message: format!("{}", error), + message: format!("{error}"), ..Default::default() })) } diff --git a/sway-lsp/src/capabilities/hover.rs b/sway-lsp/src/capabilities/hover.rs index 286b8e98d42..ee4cf856624 100644 --- a/sway-lsp/src/capabilities/hover.rs +++ b/sway-lsp/src/capabilities/hover.rs @@ -62,7 +62,7 @@ fn format_doc_attributes(token: &Token) -> String { .iter() .map(|attribute| { let comment = attribute.args.first().unwrap().as_str(); - format!("{}\n", comment) + format!("{comment}\n") }) .collect() } @@ -83,7 +83,7 @@ fn format_variable_hover(is_mutable: bool, type_name: &str, token_name: &str) -> false => "", true => " mut", }; - format!("let{} {}: {}", mutability, token_name, type_name) + format!("let{mutability} {token_name}: {type_name}") } fn markup_content(markup: Markup) -> lsp_types::MarkupContent { @@ -100,7 +100,7 @@ fn hover_format(engines: Engines<'_>, token: &Token, ident: &Ident) -> lsp_types let format_name_with_type = |name: &str, type_id: &TypeId| -> String { let type_name = format!("{}", engines.help_out(type_id)); - format!("{}: {}", name, type_name) + format!("{name}: {type_name}") }; let value = token diff --git a/sway-lsp/src/core/document.rs b/sway-lsp/src/core/document.rs index 5db7c638b20..70b1ff98f78 100644 --- a/sway-lsp/src/core/document.rs +++ b/sway-lsp/src/core/document.rs @@ -117,7 +117,7 @@ mod tests { fn build_from_path_returns_text_document() { let path = get_absolute_path("sway-lsp/test/fixtures/cats.txt"); let result = TextDocument::build_from_path(&path); - assert!(result.is_ok(), "result = {:?}", result); + assert!(result.is_ok(), "result = {result:?}"); } #[test] diff --git a/sway-lsp/src/core/session.rs b/sway-lsp/src/core/session.rs index a6a78e849ff..74406169701 100644 --- a/sway-lsp/src/core/session.rs +++ b/sway-lsp/src/core/session.rs @@ -289,7 +289,7 @@ impl Session { path: uri.path().to_string(), err: err.to_string(), })?; - writeln!(&mut file, "{}", src).map_err(|err| DocumentError::UnableToWriteFile { + writeln!(&mut file, "{src}").map_err(|err| DocumentError::UnableToWriteFile { path: uri.path().to_string(), err: err.to_string(), })?; diff --git a/sway-lsp/src/server.rs b/sway-lsp/src/server.rs index 53c4a864dce..4711163145d 100644 --- a/sway-lsp/src/server.rs +++ b/sway-lsp/src/server.rs @@ -554,7 +554,7 @@ impl Backend { let write_ast_to_file = |path: &Path, ast_string: &String| -> Option { if let Ok(mut file) = File::create(path) { - let _ = writeln!(&mut file, "{}", ast_string); + let _ = writeln!(&mut file, "{ast_string}"); if let Ok(uri) = Url::from_file_path(path) { // Return the tmp file path where the AST has been written to. return Some(TextDocumentIdentifier::new(uri)); @@ -1171,7 +1171,7 @@ mod tests { .await; socket_handle .await - .unwrap_or_else(|e| panic!("Test failed: {:?}", e)); + .unwrap_or_else(|e| panic!("Test failed: {e:?}")); shutdown_and_exit(&mut service).await; } diff --git a/sway-lsp/src/utils/debug.rs b/sway-lsp/src/utils/debug.rs index 7f78fc702b0..d60cb9827e9 100644 --- a/sway-lsp/src/utils/debug.rs +++ b/sway-lsp/src/utils/debug.rs @@ -73,52 +73,52 @@ pub(crate) fn print_decl_engine_types( let const_decl = decl_engine .get_constant(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", const_decl) + format!("{const_decl:#?}") } ty::TyDeclaration::FunctionDeclaration(decl_id) => { let func_decl = decl_engine .get_function(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", func_decl) + format!("{func_decl:#?}") } ty::TyDeclaration::TraitDeclaration(decl_id) => { let trait_decl = decl_engine .get_trait(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", trait_decl) + format!("{trait_decl:#?}") } ty::TyDeclaration::StructDeclaration(decl_id) => { let struct_decl = decl_engine .get_struct(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", struct_decl) + format!("{struct_decl:#?}") } ty::TyDeclaration::EnumDeclaration(decl_id) => { let enum_decl = decl_engine .get_enum(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", enum_decl) + format!("{enum_decl:#?}") } ty::TyDeclaration::AbiDeclaration(decl_id) => { let abi_decl = decl_engine .get_abi(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", abi_decl) + format!("{abi_decl:#?}") } ty::TyDeclaration::StorageDeclaration(decl_id) => { let storage_decl = decl_engine .get_storage(decl_id.clone(), &decl_id.span()) .unwrap(); - format!("{:#?}", storage_decl) + format!("{storage_decl:#?}") } - _ => format!("{:#?}", declaration), + _ => format!("{declaration:#?}"), }, ty::TyAstNodeContent::Expression(expression) | ty::TyAstNodeContent::ImplicitReturnExpression(expression) => { - format!("{:#?}", expression) + format!("{expression:#?}") } ty::TyAstNodeContent::SideEffect => "".to_string(), }) - .map(|s| format!("{}\n", s)) + .map(|s| format!("{s}\n")) .collect() } diff --git a/sway-lsp/src/utils/markup.rs b/sway-lsp/src/utils/markup.rs index 48c0093125d..e2634451142 100644 --- a/sway-lsp/src/utils/markup.rs +++ b/sway-lsp/src/utils/markup.rs @@ -47,7 +47,7 @@ impl Markup { /// Contents will be formatted with sway syntax highlighting. pub fn fenced_sway_block(mut self, contents: &impl fmt::Display) -> Self { - let code_block = format!("```sway\n{}\n```", contents); + let code_block = format!("```sway\n{contents}\n```"); self.text.push_str(&code_block); self } diff --git a/sway-parse/src/attribute.rs b/sway-parse/src/attribute.rs index 9c94e98ab77..e7e05c64168 100644 --- a/sway-parse/src/attribute.rs +++ b/sway-parse/src/attribute.rs @@ -91,7 +91,7 @@ impl Parse for Attribute { } impl ParseToEnd for Attribute { - fn parse_to_end<'a, 'e>(mut parser: Parser<'a, 'e>) -> ParseResult<(Self, ParserConsumed<'a>)> { + fn parse_to_end<'a, 'e>(mut parser: Parser<'a, '_>) -> ParseResult<(Self, ParserConsumed<'a>)> { let attrib = parser.parse()?; match parser.check_empty() { Some(consumed) => Ok((attrib, consumed)), diff --git a/sway-parse/src/expr/asm.rs b/sway-parse/src/expr/asm.rs index 3deaa7bcd61..94f40f25131 100644 --- a/sway-parse/src/expr/asm.rs +++ b/sway-parse/src/expr/asm.rs @@ -42,7 +42,7 @@ impl Parse for AsmRegisterDeclaration { impl ParseToEnd for AsmBlockContents { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(AsmBlockContents, ParserConsumed<'a>)> { let mut instructions = Vec::new(); let (final_expr_opt, consumed) = loop { diff --git a/sway-parse/src/expr/mod.rs b/sway-parse/src/expr/mod.rs index 1c13b33faa6..4d0a9daf574 100644 --- a/sway-parse/src/expr/mod.rs +++ b/sway-parse/src/expr/mod.rs @@ -25,7 +25,7 @@ pub mod op_code; impl ParseToEnd for AbiCastArgs { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(AbiCastArgs, ParserConsumed<'a>)> { let name = parser.parse()?; let comma_token = parser.parse()?; @@ -126,7 +126,7 @@ impl Parse for StatementLet { impl ParseToEnd for CodeBlockContents { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(CodeBlockContents, ParserConsumed<'a>)> { let mut statements = Vec::new(); let (final_expr_opt, consumed) = loop { @@ -746,7 +746,7 @@ impl Parse for ExprStructField { impl ParseToEnd for ExprArrayDescriptor { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(ExprArrayDescriptor, ParserConsumed<'a>)> { if let Some(consumed) = parser.check_empty() { let punctuated = Punctuated::empty(); diff --git a/sway-parse/src/item/mod.rs b/sway-parse/src/item/mod.rs index 9c1c8385c44..a0ec5bed2b6 100644 --- a/sway-parse/src/item/mod.rs +++ b/sway-parse/src/item/mod.rs @@ -84,7 +84,7 @@ impl Parse for TypeField { impl ParseToEnd for FnArgs { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(FnArgs, ParserConsumed<'a>)> { let mut ref_self: Option = None; let mut mutable_self: Option = None; diff --git a/sway-parse/src/module.rs b/sway-parse/src/module.rs index 0e103996030..553f1b165d3 100644 --- a/sway-parse/src/module.rs +++ b/sway-parse/src/module.rs @@ -24,7 +24,7 @@ impl Parse for ModuleKind { } impl ParseToEnd for Module { - fn parse_to_end<'a, 'e>(mut parser: Parser<'a, 'e>) -> ParseResult<(Self, ParserConsumed<'a>)> { + fn parse_to_end<'a, 'e>(mut parser: Parser<'a, '_>) -> ParseResult<(Self, ParserConsumed<'a>)> { let (kind, semicolon_token) = parser.parse()?; let (items, consumed) = parser.parse_to_end()?; diff --git a/sway-parse/src/parse.rs b/sway-parse/src/parse.rs index 39279952c7d..1ea6939b4d3 100644 --- a/sway-parse/src/parse.rs +++ b/sway-parse/src/parse.rs @@ -19,7 +19,7 @@ pub trait Peek { } pub trait ParseToEnd { - fn parse_to_end<'a, 'e>(parser: Parser<'a, 'e>) -> ParseResult<(Self, ParserConsumed<'a>)> + fn parse_to_end<'a>(parser: Parser<'a, '_>) -> ParseResult<(Self, ParserConsumed<'a>)> where Self: Sized; } @@ -89,7 +89,7 @@ where T: Parse, { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(Vec, ParserConsumed<'a>)> { let mut ret = Vec::new(); loop { diff --git a/sway-parse/src/punctuated.rs b/sway-parse/src/punctuated.rs index 947a248b2d5..5867fe01013 100644 --- a/sway-parse/src/punctuated.rs +++ b/sway-parse/src/punctuated.rs @@ -8,7 +8,7 @@ where P: Parse, { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(Punctuated, ParserConsumed<'a>)> { let mut value_separator_pairs = Vec::new(); loop { diff --git a/sway-parse/src/ty/mod.rs b/sway-parse/src/ty/mod.rs index f6e42f13034..defe2d2c180 100644 --- a/sway-parse/src/ty/mod.rs +++ b/sway-parse/src/ty/mod.rs @@ -56,7 +56,7 @@ impl Parse for Ty { impl ParseToEnd for TyArrayDescriptor { fn parse_to_end<'a, 'e>( - mut parser: Parser<'a, 'e>, + mut parser: Parser<'a, '_>, ) -> ParseResult<(TyArrayDescriptor, ParserConsumed<'a>)> { let ty = parser.parse()?; let semicolon_token = parser.parse()?; diff --git a/sway-types/src/integer_bits.rs b/sway-types/src/integer_bits.rs index f93eca5d87d..fc3bbb1f434 100644 --- a/sway-types/src/integer_bits.rs +++ b/sway-types/src/integer_bits.rs @@ -17,6 +17,6 @@ impl fmt::Display for IntegerBits { ThirtyTwo => "thirty two", SixtyFour => "sixty four", }; - write!(f, "{}", s) + write!(f, "{s}") } } diff --git a/swayfmt/src/config/manifest.rs b/swayfmt/src/config/manifest.rs index 147219896bd..1424e4211f3 100644 --- a/swayfmt/src/config/manifest.rs +++ b/swayfmt/src/config/manifest.rs @@ -122,7 +122,7 @@ impl ConfigOptions { })?; let toml_de = &mut toml::de::Deserializer::new(&config_str); let config_opts: Self = serde_ignored::deserialize(toml_de, |field| { - let warning = format!(" WARNING! found unusable configuration: {}", field); + let warning = format!(" WARNING! found unusable configuration: {field}"); println_yellow_err(&warning); }) .map_err(|e| ConfigError::Deserialize { err: (e) })?; diff --git a/swayfmt/src/formatter/mod.rs b/swayfmt/src/formatter/mod.rs index 15ca4d70124..88ef5131d14 100644 --- a/swayfmt/src/formatter/mod.rs +++ b/swayfmt/src/formatter/mod.rs @@ -1280,7 +1280,7 @@ fn main() { let mut formatter = Formatter::default(); let formatted_sway_code = Formatter::format(&mut formatter, Arc::from(sway_code_to_format), None).unwrap(); - println!("formatted: {}", formatted_sway_code); + println!("formatted: {formatted_sway_code}"); assert_eq!(correct_sway_code, formatted_sway_code); assert!(test_stability(formatted_sway_code, formatter)); } diff --git a/swayfmt/src/formatter/shape.rs b/swayfmt/src/formatter/shape.rs index 235e04e8a81..6739d46acf3 100644 --- a/swayfmt/src/formatter/shape.rs +++ b/swayfmt/src/formatter/shape.rs @@ -65,7 +65,7 @@ impl Indent { writeln!(indent)?; } for _ in 0..num_tabs { - write!(indent, "{}", HARD_TAB)?; + write!(indent, "{HARD_TAB}")?; } for _ in 0..num_spaces { write!(indent, " ")?; diff --git a/swayfmt/src/items/item_abi.rs b/swayfmt/src/items/item_abi.rs index 3f479e8f345..369549211d8 100644 --- a/swayfmt/src/items/item_abi.rs +++ b/swayfmt/src/items/item_abi.rs @@ -66,11 +66,11 @@ impl CurlyBrace for ItemAbi { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add openning brace to the next line. - write!(line, "\n{}\n", open_brace)?; + write!(line, "\n{open_brace}\n")?; } _ => { // Add opening brace to the same line - writeln!(line, " {}", open_brace)?; + writeln!(line, " {open_brace}")?; } } diff --git a/swayfmt/src/items/item_enum/mod.rs b/swayfmt/src/items/item_enum/mod.rs index d44cb008324..cdd8e905c0d 100644 --- a/swayfmt/src/items/item_enum/mod.rs +++ b/swayfmt/src/items/item_enum/mod.rs @@ -137,12 +137,12 @@ impl CurlyBrace for ItemEnum { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add openning brace to the next line. - writeln!(line, "\n{}", open_brace)?; + writeln!(line, "\n{open_brace}")?; formatter.shape.block_indent(&formatter.config); } _ => { // Add opening brace to the same line - write!(line, " {}", open_brace)?; + write!(line, " {open_brace}")?; formatter.shape.block_indent(&formatter.config); } } diff --git a/swayfmt/src/items/item_fn/mod.rs b/swayfmt/src/items/item_fn/mod.rs index 90edfee1cda..4a6760175f5 100644 --- a/swayfmt/src/items/item_fn/mod.rs +++ b/swayfmt/src/items/item_fn/mod.rs @@ -59,23 +59,23 @@ impl CurlyBrace for ItemFn { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add openning brace to the next line. - writeln!(line, "\n{}", open_brace)?; + writeln!(line, "\n{open_brace}")?; formatter.shape.block_indent(&formatter.config); } ItemBraceStyle::SameLineWhere => match formatter.shape.code_line.has_where_clause { true => { - write!(line, "{}", open_brace)?; + write!(line, "{open_brace}")?; formatter.shape.code_line.update_where_clause(false); formatter.shape.block_indent(&formatter.config); } false => { - write!(line, " {}", open_brace)?; + write!(line, " {open_brace}")?; formatter.shape.block_indent(&formatter.config); } }, _ => { // TODO: implement PreferSameLine - writeln!(line, " {}", open_brace)?; + writeln!(line, " {open_brace}")?; formatter.shape.block_indent(&formatter.config); } } diff --git a/swayfmt/src/items/item_impl/mod.rs b/swayfmt/src/items/item_impl/mod.rs index 15b896e7113..28b0ed18bf0 100644 --- a/swayfmt/src/items/item_impl/mod.rs +++ b/swayfmt/src/items/item_impl/mod.rs @@ -62,20 +62,20 @@ impl CurlyBrace for ItemImpl { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add opening brace to the next line. - writeln!(line, "\n{}", open_brace)?; + writeln!(line, "\n{open_brace}")?; } ItemBraceStyle::SameLineWhere => match formatter.shape.code_line.has_where_clause { true => { - writeln!(line, "{}", open_brace)?; + writeln!(line, "{open_brace}")?; formatter.shape.code_line.update_where_clause(false); } false => { - writeln!(line, " {}", open_brace)?; + writeln!(line, " {open_brace}")?; } }, _ => { // TODO: implement PreferSameLine - writeln!(line, " {}", open_brace)?; + writeln!(line, " {open_brace}")?; } } diff --git a/swayfmt/src/items/item_storage/mod.rs b/swayfmt/src/items/item_storage/mod.rs index acef9daed7a..69ad6114fb7 100644 --- a/swayfmt/src/items/item_storage/mod.rs +++ b/swayfmt/src/items/item_storage/mod.rs @@ -129,11 +129,11 @@ impl CurlyBrace for ItemStorage { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add opening brace to the next line. - write!(line, "\n{}", open_brace)?; + write!(line, "\n{open_brace}")?; } _ => { // Add opening brace to the same line - write!(line, " {}", open_brace)?; + write!(line, " {open_brace}")?; } } diff --git a/swayfmt/src/items/item_trait.rs b/swayfmt/src/items/item_trait.rs index ce59e5f9d77..73a91a68839 100644 --- a/swayfmt/src/items/item_trait.rs +++ b/swayfmt/src/items/item_trait.rs @@ -99,10 +99,10 @@ impl CurlyBrace for ItemTrait { match brace_style { ItemBraceStyle::AlwaysNextLine => { // Add openning brace to the next line. - writeln!(line, "\n{}", open_brace)?; + writeln!(line, "\n{open_brace}")?; } _ => { - writeln!(line, "{}", open_brace)?; + writeln!(line, "{open_brace}")?; } } diff --git a/swayfmt/src/items/item_use/mod.rs b/swayfmt/src/items/item_use/mod.rs index 3b4a787caaa..e452522fe35 100644 --- a/swayfmt/src/items/item_use/mod.rs +++ b/swayfmt/src/items/item_use/mod.rs @@ -103,7 +103,7 @@ impl Format for UseTree { if import_str.ends_with(PunctKind::Comma.as_char()) { import_str.pop(); } - write!(formatted_code, "{}", import_str)?; + write!(formatted_code, "{import_str}")?; } } Self::close_curly_brace(formatted_code, formatter)?; diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index bdddbb76644..cc689a32281 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -63,8 +63,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> deploy(DeployCommand { path: Some(format!( - "{}/src/e2e_vm_tests/test_programs/{}", - manifest_dir, file_name + "{manifest_dir}/src/e2e_vm_tests/test_programs/{file_name}" )), terse_mode: !run_config.verbose, locked: run_config.locked, @@ -92,14 +91,13 @@ pub(crate) async fn runs_on_node( let mut contracts = Vec::::with_capacity(contract_ids.len()); for contract_id in contract_ids { - let contract = format!("0x{:x}", contract_id); + let contract = format!("0x{contract_id:x}"); contracts.push(contract); } let command = RunCommand { path: Some(format!( - "{}/src/e2e_vm_tests/test_programs/{}", - manifest_dir, file_name + "{manifest_dir}/src/e2e_vm_tests/test_programs/{file_name}" )), node_url: Some(NODE_URL.into()), terse_mode: !run_config.verbose, @@ -179,8 +177,7 @@ pub(crate) async fn compile_to_bytes(file_name: &str, run_config: &RunConfig) -> build_target: run_config.build_target, pkg: forc_pkg::PkgOpts { path: Some(format!( - "{}/src/e2e_vm_tests/test_programs/{}", - manifest_dir, file_name + "{manifest_dir}/src/e2e_vm_tests/test_programs/{file_name}" )), locked: run_config.locked, terse: false, @@ -192,7 +189,7 @@ pub(crate) async fn compile_to_bytes(file_name: &str, run_config: &RunConfig) -> // Print the result of the compilation (i.e., any errors Forc produces). if let Err(ref e) = result { - println!("\n{}", e); + println!("\n{e}"); } result diff --git a/test/src/e2e_vm_tests/mod.rs b/test/src/e2e_vm_tests/mod.rs index f05ba24f8a7..09f3191de59 100644 --- a/test/src/e2e_vm_tests/mod.rs +++ b/test/src/e2e_vm_tests/mod.rs @@ -46,10 +46,10 @@ enum TestResult { impl fmt::Debug for TestResult { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - TestResult::Result(result) => write!(f, "Result({})", result), - TestResult::Return(code) => write!(f, "Return({})", code), + TestResult::Result(result) => write!(f, "Result({result})"), + TestResult::Return(code) => write!(f, "Return({code})"), TestResult::ReturnData(data) => write!(f, "ReturnData(0x{})", hex::encode(data)), - TestResult::Revert(code) => write!(f, "Revert({})", code), + TestResult::Revert(code) => write!(f, "Revert({code})"), } } } @@ -158,8 +158,7 @@ impl TestContext { if result != res { Err(anyhow::Error::msg(format!( - "expected: {:?}\nactual: {:?}", - res, result + "expected: {res:?}\nactual: {result:?}" ))) } else { if validate_abi { @@ -317,8 +316,7 @@ impl TestContext { } category => Err(anyhow::Error::msg(format!( - "Unexpected test category: {:?}", - category, + "Unexpected test category: {category:?}", ))), } }