nojob1 2 лет назад
Родитель
Сommit
872d084e00

+ 7 - 10
avm/src/lib.rs

@@ -40,7 +40,7 @@ pub fn current_version() -> Result<Version> {
 /// Path to the binary for the given version
 pub fn version_binary_path(version: &Version) -> PathBuf {
     let mut version_path = AVM_HOME.join("bin");
-    version_path.push(format!("anchor-{}", version));
+    version_path.push(format!("anchor-{version}"));
     version_path
 }
 
@@ -50,12 +50,9 @@ pub fn use_version(version: &Version) -> Result<()> {
     // Make sure the requested version is installed
     if !installed_versions.contains(version) {
         if let Ok(current) = current_version() {
-            println!(
-                "Version {} is not installed, staying on version {}.",
-                version, current
-            );
+            println!("Version {version} is not installed, staying on version {current}.");
         } else {
-            println!("Version {} is not installed, no current version.", version);
+            println!("Version {version} is not installed, no current version.");
         }
 
         return Err(anyhow!(
@@ -83,7 +80,7 @@ pub fn install_version(version: &Version, force: bool) -> Result<()> {
     // If version is already installed we ignore the request.
     let installed_versions = read_installed_versions();
     if installed_versions.contains(version) && !force {
-        println!("Version {} is already installed", version);
+        println!("Version {version} is already installed");
         return Ok(());
     }
 
@@ -113,7 +110,7 @@ pub fn install_version(version: &Version, force: bool) -> Result<()> {
     }
     fs::rename(
         AVM_HOME.join("bin").join("anchor"),
-        AVM_HOME.join("bin").join(format!("anchor-{}", version)),
+        AVM_HOME.join("bin").join(format!("anchor-{version}")),
     )?;
     // If .version file is empty or not parseable, write the newly installed version to it
     if current_version().is_err() {
@@ -126,7 +123,7 @@ pub fn install_version(version: &Version, force: bool) -> Result<()> {
 
 /// Remove an installed version of anchor-cli
 pub fn uninstall_version(version: &Version) -> Result<()> {
-    let version_path = AVM_HOME.join("bin").join(format!("anchor-{}", version));
+    let version_path = AVM_HOME.join("bin").join(format!("anchor-{version}"));
     if !version_path.exists() {
         return Err(anyhow!("anchor-cli {} is not installed", version));
     }
@@ -189,7 +186,7 @@ pub fn list_versions() -> Result<()> {
     available_versions.reverse();
 
     available_versions.iter().enumerate().for_each(|(i, v)| {
-        print!("{}", v);
+        print!("{v}");
         let mut flags = vec![];
         if i == available_versions.len() - 1 {
             flags.push("latest");

+ 3 - 3
cli/src/config.rs

@@ -180,7 +180,7 @@ impl WithPath<Config> {
             let cargo = Manifest::from_path(path.join("Cargo.toml"))?;
             let lib_name = cargo.lib_name()?;
 
-            let idl_filepath = format!("target/idl/{}.json", lib_name);
+            let idl_filepath = format!("target/idl/{lib_name}.json");
             let idl = fs::read(idl_filepath)
                 .ok()
                 .map(|bytes| serde_json::from_reader(&*bytes))
@@ -353,7 +353,7 @@ impl Config {
             .anchor_version
             .clone()
             .unwrap_or_else(|| crate::DOCKER_BUILDER_VERSION.to_string());
-        format!("projectserum/build:v{}", ver)
+        format!("projectserum/build:v{ver}")
     }
 
     pub fn discover(cfg_override: &ConfigOverride) -> Result<Option<WithPath<Config>>> {
@@ -1101,7 +1101,7 @@ impl Program {
     pub fn keypair_file(&self) -> Result<WithPath<File>> {
         let deploy_dir_path = "target/deploy/";
         fs::create_dir_all(deploy_dir_path)
-            .with_context(|| format!("Error creating directory with path: {}", deploy_dir_path))?;
+            .with_context(|| format!("Error creating directory with path: {deploy_dir_path}"))?;
         let path = std::env::current_dir()
             .expect("Must have current dir")
             .join(format!("target/deploy/{}-keypair.json", self.lib_name));

+ 34 - 36
cli/src/lib.rs

@@ -655,7 +655,7 @@ fn init(
         }
     }
 
-    println!("{} initialized", project_name);
+    println!("{project_name} initialized");
 
     Ok(())
 }
@@ -663,7 +663,7 @@ fn init(
 fn install_node_modules(cmd: &str) -> Result<std::process::Output> {
     if cfg!(target_os = "windows") {
         std::process::Command::new("cmd")
-            .arg(format!("/C {} install", cmd))
+            .arg(format!("/C {cmd} install"))
             .stdout(Stdio::inherit())
             .stderr(Stdio::inherit())
             .output()
@@ -697,13 +697,13 @@ fn new(cfg_override: &ConfigOverride, name: String) -> Result<()> {
 
 // Creates a new program crate in the current directory with `name`.
 fn new_program(name: &str) -> Result<()> {
-    fs::create_dir(format!("programs/{}", name))?;
-    fs::create_dir(format!("programs/{}/src/", name))?;
-    let mut cargo_toml = File::create(format!("programs/{}/Cargo.toml", name))?;
+    fs::create_dir(format!("programs/{name}"))?;
+    fs::create_dir(format!("programs/{name}/src/"))?;
+    let mut cargo_toml = File::create(format!("programs/{name}/Cargo.toml"))?;
     cargo_toml.write_all(template::cargo_toml(name).as_bytes())?;
-    let mut xargo_toml = File::create(format!("programs/{}/Xargo.toml", name))?;
+    let mut xargo_toml = File::create(format!("programs/{name}/Xargo.toml"))?;
     xargo_toml.write_all(template::xargo_toml().as_bytes())?;
-    let mut lib_rs = File::create(format!("programs/{}/src/lib.rs", name))?;
+    let mut lib_rs = File::create(format!("programs/{name}/src/lib.rs"))?;
     lib_rs.write_all(template::lib_rs(name).as_bytes())?;
     Ok(())
 }
@@ -780,7 +780,7 @@ fn expand_program(
     let exit = std::process::Command::new("cargo")
         .arg("expand")
         .arg(target_dir_arg)
-        .arg(&format!("--package={}", package_name))
+        .arg(&format!("--package={package_name}"))
         .args(cargo_args)
         .stderr(Stdio::inherit())
         .output()
@@ -792,8 +792,7 @@ fn expand_program(
 
     let version = cargo.version();
     let time = chrono::Utc::now().to_string().replace(' ', "_");
-    let file_path =
-        program_expansions_path.join(format!("{}-{}-{}.rs", package_name, version, time));
+    let file_path = program_expansions_path.join(format!("{package_name}-{version}-{time}.rs"));
     fs::write(&file_path, &exit.stdout).map_err(|e| anyhow::format_err!("{}", e.to_string()))?;
 
     println!(
@@ -1017,7 +1016,7 @@ fn build_cwd_verifiable(
 
     match &result {
         Err(e) => {
-            eprintln!("Error during Docker build: {:?}", e);
+            eprintln!("Error during Docker build: {e:?}");
         }
         Ok(_) => {
             // Build the idl.
@@ -1149,7 +1148,7 @@ fn docker_prep(container_name: &str, build_config: &BuildConfig) -> Result<()> {
     }
 
     if let Some(solana_version) = &build_config.solana_version {
-        println!("Using solana version: {}", solana_version);
+        println!("Using solana version: {solana_version}");
 
         // Install Solana CLI
         docker_exec(
@@ -1157,7 +1156,7 @@ fn docker_prep(container_name: &str, build_config: &BuildConfig) -> Result<()> {
             &[
                 "curl",
                 "-sSfL",
-                &format!("https://release.solana.com/v{0}/install", solana_version,),
+                &format!("https://release.solana.com/v{solana_version}/install",),
                 "-o",
                 "solana_installer.sh",
             ],
@@ -1227,14 +1226,14 @@ fn docker_build_bpf(
     println!("Copying out the build artifacts");
     let out_file = cfg_parent
         .canonicalize()?
-        .join(format!("target/verifiable/{}.so", binary_name))
+        .join(format!("target/verifiable/{binary_name}.so"))
         .display()
         .to_string();
 
     // This requires the target directory of any built program to be located at
     // the root of the workspace.
     let mut bin_path = target_dir.join("deploy");
-    bin_path.push(format!("{}.so", binary_name));
+    bin_path.push(format!("{binary_name}.so"));
     let bin_artifact = format!(
         "{}:{}",
         container_name,
@@ -1387,7 +1386,7 @@ fn verify(
         .parent()
         .ok_or_else(|| anyhow!("Unable to find workspace root"))?
         .join("target/verifiable/")
-        .join(format!("{}.so", binary_name));
+        .join(format!("{binary_name}.so"));
 
     let url = cluster_url(&cfg, &cfg.test_validator);
     let bin_ver = verify_bin(program_id, &bin_path, &url)?;
@@ -1407,7 +1406,7 @@ fn verify(
         }
     }
 
-    println!("{} is verified.", program_id);
+    println!("{program_id} is verified.");
 
     Ok(())
 }
@@ -1639,7 +1638,7 @@ fn idl_init(cfg_override: &ConfigOverride, program_id: Pubkey, idl_filepath: Str
 
         let idl_address = create_idl_account(cfg, &keypair, &program_id, &idl)?;
 
-        println!("Idl account created: {:?}", idl_address);
+        println!("Idl account created: {idl_address:?}");
         Ok(())
     })
 }
@@ -1649,7 +1648,7 @@ fn idl_close(cfg_override: &ConfigOverride, program_id: Pubkey) -> Result<()> {
         let idl_address = IdlAccount::address(&program_id);
         idl_close_account(cfg, &program_id, idl_address)?;
 
-        println!("Idl account closed: {:?}", idl_address);
+        println!("Idl account closed: {idl_address:?}");
 
         Ok(())
     })
@@ -1669,7 +1668,7 @@ fn idl_write_buffer(
         let idl_buffer = create_idl_buffer(cfg, &keypair, &program_id, &idl)?;
         idl_write(cfg, &program_id, &idl, idl_buffer)?;
 
-        println!("Idl buffer created: {:?}", idl_buffer);
+        println!("Idl buffer created: {idl_buffer:?}");
 
         Ok(idl_buffer)
     })
@@ -1966,7 +1965,7 @@ fn idl_fetch(cfg_override: &ConfigOverride, address: Pubkey, out: Option<String>
 fn write_idl(idl: &Idl, out: OutFile) -> Result<()> {
     let idl_json = serde_json::to_string_pretty(idl)?;
     match out {
-        OutFile::Stdout => println!("{}", idl_json),
+        OutFile::Stdout => println!("{idl_json}"),
         OutFile::File(out) => fs::write(out, idl_json)?,
     };
 
@@ -1997,7 +1996,7 @@ fn account(
                 .expect("Workspace must contain atleast one program.")
                 .iter()
                 .find(|&p| p.lib_name == *program_name)
-                .unwrap_or_else(|| panic!("Program {} not found in workspace.", program_name))
+                .unwrap_or_else(|| panic!("Program {program_name} not found in workspace."))
                 .idl
                 .as_ref()
                 .expect("IDL not found. Please build the program atleast once to generate the IDL.")
@@ -2008,7 +2007,7 @@ fn account(
             let idl: Idl = serde_json::from_reader(&*bytes).expect("Invalid IDL format.");
 
             if idl.name != program_name {
-                panic!("IDL does not match program {}.", program_name);
+                panic!("IDL does not match program {program_name}.");
             }
 
             idl
@@ -2073,7 +2072,7 @@ fn deserialize_idl_struct_to_json(
 
             let variant = variants
                 .get(repr as usize)
-                .unwrap_or_else(|| panic!("Error while deserializing enum variant {}", repr));
+                .unwrap_or_else(|| panic!("Error while deserializing enum variant {repr}"));
 
             let mut value = json!({});
 
@@ -2402,7 +2401,7 @@ fn run_test_suite(
             }
         }
         Err(err) => {
-            println!("Failed to run test: {:#}", err);
+            println!("Failed to run test: {err:#}");
             return Err(err);
         }
     }
@@ -2678,8 +2677,7 @@ fn start_test_validator(
     }
     if count == ms_wait {
         eprintln!(
-            "Unable to get latest blockhash. Test validator does not look started. Check {} for errors. Consider increasing [test.startup_wait] in Anchor.toml.",
-            test_ledger_log_filename
+            "Unable to get latest blockhash. Test validator does not look started. Check {test_ledger_log_filename} for errors. Consider increasing [test.startup_wait] in Anchor.toml."
         );
         validator_handle.kill()?;
         std::process::exit(1);
@@ -2713,7 +2711,7 @@ fn test_validator_file_paths(test_validator: &Option<TestValidator>) -> (String,
     if !Path::new(&ledger_directory).is_relative() {
         // Prevent absolute paths to avoid someone using / or similar, as the
         // directory gets removed
-        eprintln!("Ledger directory {} must be relative", ledger_directory);
+        eprintln!("Ledger directory {ledger_directory} must be relative");
         std::process::exit(1);
     }
     if Path::new(&ledger_directory).exists() {
@@ -2724,7 +2722,7 @@ fn test_validator_file_paths(test_validator: &Option<TestValidator>) -> (String,
 
     (
         ledger_directory.to_string(),
-        format!("{}/test-ledger-log.txt", ledger_directory),
+        format!("{ledger_directory}/test-ledger-log.txt"),
     )
 }
 
@@ -2776,8 +2774,8 @@ fn deploy(
         let keypair = cfg.provider.wallet.to_string();
 
         // Deploy the programs.
-        println!("Deploying workspace: {}", url);
-        println!("Upgrade authority: {}", keypair);
+        println!("Deploying workspace: {url}");
+        println!("Upgrade authority: {keypair}");
 
         for mut program in cfg.read_all_programs()? {
             if let Some(single_prog_str) = &program_str {
@@ -2793,7 +2791,7 @@ fn deploy(
                 program.path.file_name().unwrap().to_str().unwrap()
             );
 
-            println!("Program path: {}...", binary_path);
+            println!("Program path: {binary_path}...");
 
             let program_keypair_filepath = match &program_keypair {
                 Some(program_keypair) => program_keypair.clone(),
@@ -2816,7 +2814,7 @@ fn deploy(
                 .output()
                 .expect("Must deploy");
             if !exit.status.success() {
-                println!("There was a problem deploying: {:?}.", exit);
+                println!("There was a problem deploying: {exit:?}.");
                 std::process::exit(exit.status.code().unwrap_or(1));
             }
 
@@ -2866,7 +2864,7 @@ fn upgrade(
             .output()
             .expect("Must deploy");
         if !exit.status.success() {
-            println!("There was a problem deploying: {:?}.", exit);
+            println!("There was a problem deploying: {exit:?}.");
             std::process::exit(exit.status.code().unwrap_or(1));
         }
         Ok(())
@@ -3085,7 +3083,7 @@ fn migrate(cfg_override: &ConfigOverride) -> Result<()> {
 fn set_workspace_dir_or_exit() {
     let d = match Config::discover(&ConfigOverride::default()) {
         Err(err) => {
-            println!("Workspace configuration error: {}", err);
+            println!("Workspace configuration error: {err}");
             std::process::exit(1);
         }
         Ok(d) => d,
@@ -3292,7 +3290,7 @@ fn publish(
     // Create the workspace tarball.
     let dot_anchor = workspace_dir.join(".anchor");
     fs::create_dir_all(&dot_anchor)?;
-    let tarball_filename = dot_anchor.join(format!("{}.tar.gz", program_name));
+    let tarball_filename = dot_anchor.join(format!("{program_name}.tar.gz"));
     let tar_gz = File::create(&tarball_filename)?;
     let enc = GzEncoder::new(tar_gz, Compression::default());
     let mut tar = tar::Builder::new(enc);

+ 16 - 24
cli/src/template.rs

@@ -32,9 +32,8 @@ codegen-units = 1
 pub fn credentials(token: &str) -> String {
     format!(
         r#"[registry]
-token = "{}"
-"#,
-        token
+token = "{token}"
+"#
     )
 }
 
@@ -90,10 +89,10 @@ pub fn deploy_js_script_host(cluster_url: &str, script_path: &str) -> String {
 const anchor = require('@coral-xyz/anchor');
 
 // Deploy script defined by the user.
-const userScript = require("{0}");
+const userScript = require("{script_path}");
 
 async function main() {{
-    const url = "{1}";
+    const url = "{cluster_url}";
     const preflightCommitment = 'recent';
     const connection = new anchor.web3.Connection(url, preflightCommitment);
     const wallet = anchor.Wallet.local();
@@ -108,7 +107,6 @@ async function main() {{
 }}
 main();
 "#,
-        script_path, cluster_url,
     )
 }
 
@@ -117,10 +115,10 @@ pub fn deploy_ts_script_host(cluster_url: &str, script_path: &str) -> String {
         r#"import * as anchor from '@coral-xyz/anchor';
 
 // Deploy script defined by the user.
-const userScript = require("{0}");
+const userScript = require("{script_path}");
 
 async function main() {{
-    const url = "{1}";
+    const url = "{cluster_url}";
     const preflightCommitment = 'recent';
     const connection = new anchor.web3.Connection(url, preflightCommitment);
     const wallet = anchor.Wallet.local();
@@ -135,7 +133,6 @@ async function main() {{
 }}
 main();
 "#,
-        script_path, cluster_url,
     )
 }
 
@@ -251,15 +248,14 @@ pub fn package_json(jest: bool) -> String {
             "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
         }},
         "dependencies": {{
-            "@coral-xyz/anchor": "^{0}"
+            "@coral-xyz/anchor": "^{VERSION}"
         }},
         "devDependencies": {{
             "jest": "^29.0.3",
             "prettier": "^2.6.2"
         }}
     }}
-    "#,
-            VERSION
+    "#
         )
     } else {
         format!(
@@ -269,7 +265,7 @@ pub fn package_json(jest: bool) -> String {
         "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
     }},
     "dependencies": {{
-        "@coral-xyz/anchor": "^{0}"
+        "@coral-xyz/anchor": "^{VERSION}"
     }},
     "devDependencies": {{
         "chai": "^4.3.4",
@@ -277,8 +273,7 @@ pub fn package_json(jest: bool) -> String {
         "prettier": "^2.6.2"
     }}
 }}
-"#,
-            VERSION
+"#
         )
     }
 }
@@ -292,7 +287,7 @@ pub fn ts_package_json(jest: bool) -> String {
             "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
         }},
         "dependencies": {{
-            "@coral-xyz/anchor": "^{0}"
+            "@coral-xyz/anchor": "^{VERSION}"
         }},
         "devDependencies": {{
             "@types/bn.js": "^5.1.0",
@@ -303,8 +298,7 @@ pub fn ts_package_json(jest: bool) -> String {
             "typescript": "^4.3.5"
         }}
     }}
-    "#,
-            VERSION
+    "#
         )
     } else {
         format!(
@@ -314,7 +308,7 @@ pub fn ts_package_json(jest: bool) -> String {
         "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
     }},
     "dependencies": {{
-        "@coral-xyz/anchor": "^{0}"
+        "@coral-xyz/anchor": "^{VERSION}"
     }},
     "devDependencies": {{
         "chai": "^4.3.4",
@@ -327,8 +321,7 @@ pub fn ts_package_json(jest: bool) -> String {
         "prettier": "^2.6.2"
     }}
 }}
-"#,
-            VERSION
+"#
         )
     }
 }
@@ -455,7 +448,7 @@ const __wallet = new anchor.Wallet(
     Buffer.from(
       JSON.parse(
         require('fs').readFileSync(
-          "{}",
+          "{wallet_path}",
           {{
             encoding: "utf-8",
           }},
@@ -464,14 +457,13 @@ const __wallet = new anchor.Wallet(
     ),
   ),
 );
-const __connection = new web3.Connection("{}", "processed");
+const __connection = new web3.Connection("{cluster_url}", "processed");
 const provider = new anchor.AnchorProvider(__connection, __wallet, {{
   commitment: "processed",
   preflightcommitment: "processed",
 }});
 anchor.setProvider(provider);
 "#,
-        wallet_path, cluster_url,
     );
 
     for program in programs {

+ 1 - 1
client/src/cluster.rs

@@ -67,7 +67,7 @@ impl std::fmt::Display for Cluster {
             Cluster::Debug => "debug",
             Cluster::Custom(url, _ws_url) => url,
         };
-        write!(f, "{}", clust_str)
+        write!(f, "{clust_str}")
     }
 }
 

+ 2 - 2
client/src/lib.rs

@@ -203,7 +203,7 @@ impl Program {
                                         if self_program_str == execution.program() {
                                             handle_program_log(&self_program_str, l).unwrap_or_else(
                                                 |e| {
-                                                    println!("Unable to parse log: {}", e);
+                                                    println!("Unable to parse log: {e}");
                                                     std::process::exit(1);
                                                 },
                                             )
@@ -297,7 +297,7 @@ fn handle_program_log<T: anchor_lang::Event + anchor_lang::AnchorDeserialize>(
 }
 
 fn handle_system_log(this_program_str: &str, log: &str) -> (Option<String>, bool) {
-    if log.starts_with(&format!("Program {} log:", this_program_str)) {
+    if log.starts_with(&format!("Program {this_program_str} log:")) {
         (Some(this_program_str.to_string()), false)
     } else if log.contains("invoke") {
         (Some("cpi".to_string()), false) // Any string will do.

+ 2 - 2
lang/attribute/access-control/src/lib.rs

@@ -55,8 +55,8 @@ pub fn access_control(
     let access_control: Vec<proc_macro2::TokenStream> = args
         .split(')')
         .filter(|ac| !ac.is_empty())
-        .map(|ac| format!("{})", ac)) // Put back on the split char.
-        .map(|ac| format!("{}?;", ac)) // Add `?;` syntax.
+        .map(|ac| format!("{ac})")) // Put back on the split char.
+        .map(|ac| format!("{ac}?;")) // Add `?;` syntax.
         .map(|ac| ac.parse().unwrap())
         .collect();
 

+ 5 - 5
lang/attribute/account/src/lib.rs

@@ -103,9 +103,9 @@ pub fn account(
         let discriminator_preimage = {
             // For now, zero copy accounts can't be namespaced.
             if namespace.is_empty() {
-                format!("account:{}", account_name)
+                format!("account:{account_name}")
             } else {
-                format!("{}:{}", namespace, account_name)
+                format!("{namespace}:{account_name}")
             }
         };
 
@@ -113,7 +113,7 @@ pub fn account(
         discriminator.copy_from_slice(
             &anchor_syn::hash::hash(discriminator_preimage.as_bytes()).to_bytes()[..8],
         );
-        format!("{:?}", discriminator).parse().unwrap()
+        format!("{discriminator:?}").parse().unwrap()
     };
 
     let owner_impl = {
@@ -280,9 +280,9 @@ pub fn derive_zero_copy_accessor(item: proc_macro::TokenStream) -> proc_macro::T
                     let field_name = field.ident.as_ref().unwrap();
 
                     let get_field: proc_macro2::TokenStream =
-                        format!("get_{}", field_name).parse().unwrap();
+                        format!("get_{field_name}").parse().unwrap();
                     let set_field: proc_macro2::TokenStream =
-                        format!("set_{}", field_name).parse().unwrap();
+                        format!("set_{field_name}").parse().unwrap();
 
                     quote! {
                         pub fn #get_field(&self) -> #accessor_ty {

+ 2 - 2
lang/attribute/event/src/lib.rs

@@ -19,12 +19,12 @@ pub fn event(
     let event_name = &event_strct.ident;
 
     let discriminator: proc_macro2::TokenStream = {
-        let discriminator_preimage = format!("event:{}", event_name);
+        let discriminator_preimage = format!("event:{event_name}");
         let mut discriminator = [0u8; 8];
         discriminator.copy_from_slice(
             &anchor_syn::hash::hash(discriminator_preimage.as_bytes()).to_bytes()[..8],
         );
-        format!("{:?}", discriminator).parse().unwrap()
+        format!("{discriminator:?}").parse().unwrap()
     };
 
     proc_macro::TokenStream::from(quote! {

+ 1 - 1
lang/derive/space/src/lib.rs

@@ -142,7 +142,7 @@ fn len_from_type(ty: Type, attrs: &mut Option<IntoIter<LitInt>>) -> TokenStream2
                 }
             }
         }
-        _ => panic!("Type {:?} is not supported", ty),
+        _ => panic!("Type {ty:?} is not supported"),
     }
 }
 

+ 26 - 26
lang/src/system_program.rs

@@ -12,8 +12,8 @@ impl anchor_lang::Id for System {
     }
 }
 
-pub fn advance_nonce_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, AdvanceNonceAccount<'info>>,
+pub fn advance_nonce_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, AdvanceNonceAccount<'info>>,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::advance_nonce_account(
         ctx.accounts.nonce.key,
@@ -38,8 +38,8 @@ pub struct AdvanceNonceAccount<'info> {
     pub recent_blockhashes: AccountInfo<'info>,
 }
 
-pub fn allocate<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Allocate<'info>>,
+pub fn allocate<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, Allocate<'info>>,
     space: u64,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::allocate(
@@ -59,8 +59,8 @@ pub struct Allocate<'info> {
     pub account_to_allocate: AccountInfo<'info>,
 }
 
-pub fn allocate_with_seed<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, AllocateWithSeed<'info>>,
+pub fn allocate_with_seed<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, AllocateWithSeed<'info>>,
     seed: &str,
     space: u64,
     owner: &Pubkey,
@@ -86,8 +86,8 @@ pub struct AllocateWithSeed<'info> {
     pub base: AccountInfo<'info>,
 }
 
-pub fn assign<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Assign<'info>>,
+pub fn assign<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, Assign<'info>>,
     owner: &Pubkey,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::assign(
@@ -107,8 +107,8 @@ pub struct Assign<'info> {
     pub account_to_assign: AccountInfo<'info>,
 }
 
-pub fn assign_with_seed<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, AssignWithSeed<'info>>,
+pub fn assign_with_seed<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, AssignWithSeed<'info>>,
     seed: &str,
     owner: &Pubkey,
 ) -> Result<()> {
@@ -132,8 +132,8 @@ pub struct AssignWithSeed<'info> {
     pub base: AccountInfo<'info>,
 }
 
-pub fn authorize_nonce_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, AuthorizeNonceAccount<'info>>,
+pub fn authorize_nonce_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, AuthorizeNonceAccount<'info>>,
     new_authority: &Pubkey,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::authorize_nonce_account(
@@ -155,8 +155,8 @@ pub struct AuthorizeNonceAccount<'info> {
     pub authorized: AccountInfo<'info>,
 }
 
-pub fn create_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, CreateAccount<'info>>,
+pub fn create_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, CreateAccount<'info>>,
     lamports: u64,
     space: u64,
     owner: &Pubkey,
@@ -182,8 +182,8 @@ pub struct CreateAccount<'info> {
     pub to: AccountInfo<'info>,
 }
 
-pub fn create_account_with_seed<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, CreateAccountWithSeed<'info>>,
+pub fn create_account_with_seed<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, CreateAccountWithSeed<'info>>,
     seed: &str,
     lamports: u64,
     space: u64,
@@ -213,8 +213,8 @@ pub struct CreateAccountWithSeed<'info> {
     pub base: AccountInfo<'info>,
 }
 
-pub fn create_nonce_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, CreateNonceAccount<'info>>,
+pub fn create_nonce_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, CreateNonceAccount<'info>>,
     lamports: u64,
     authority: &Pubkey,
 ) -> Result<()> {
@@ -250,8 +250,8 @@ pub struct CreateNonceAccount<'info> {
     pub rent: AccountInfo<'info>,
 }
 
-pub fn create_nonce_account_with_seed<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, CreateNonceAccountWithSeed<'info>>,
+pub fn create_nonce_account_with_seed<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, CreateNonceAccountWithSeed<'info>>,
     lamports: u64,
     seed: &str,
     authority: &Pubkey,
@@ -295,8 +295,8 @@ pub struct CreateNonceAccountWithSeed<'info> {
     pub rent: AccountInfo<'info>,
 }
 
-pub fn transfer<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Transfer<'info>>,
+pub fn transfer<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, Transfer<'info>>,
     lamports: u64,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::transfer(
@@ -318,8 +318,8 @@ pub struct Transfer<'info> {
     pub to: AccountInfo<'info>,
 }
 
-pub fn transfer_with_seed<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, TransferWithSeed<'info>>,
+pub fn transfer_with_seed<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, TransferWithSeed<'info>>,
     from_seed: String,
     from_owner: &Pubkey,
     lamports: u64,
@@ -347,8 +347,8 @@ pub struct TransferWithSeed<'info> {
     pub to: AccountInfo<'info>,
 }
 
-pub fn withdraw_nonce_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, WithdrawNonceAccount<'info>>,
+pub fn withdraw_nonce_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, WithdrawNonceAccount<'info>>,
     lamports: u64,
 ) -> Result<()> {
     let ix = crate::solana_program::system_instruction::withdraw_nonce_account(

+ 3 - 6
lang/syn/src/codegen/accounts/__client_accounts.rs

@@ -25,8 +25,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
                     docs.iter()
                         .map(|docs_line| {
                             proc_macro2::TokenStream::from_str(&format!(
-                                "#[doc = r#\"{}\"#]",
-                                docs_line
+                                "#[doc = r#\"{docs_line}\"#]"
                             ))
                             .unwrap()
                         })
@@ -52,8 +51,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
                     docs.iter()
                         .map(|docs_line| {
                             proc_macro2::TokenStream::from_str(&format!(
-                                "#[doc = r#\"{}\"#]",
-                                docs_line
+                                "#[doc = r#\"{docs_line}\"#]"
                             ))
                             .unwrap()
                         })
@@ -147,8 +145,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
     };
 
     let struct_doc = proc_macro2::TokenStream::from_str(&format!(
-        "#[doc = \" Generated client accounts for [`{}`].\"]",
-        name
+        "#[doc = \" Generated client accounts for [`{name}`].\"]"
     ))
     .unwrap();
 

+ 3 - 6
lang/syn/src/codegen/accounts/__cpi_client_accounts.rs

@@ -26,8 +26,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
                     docs.iter()
                         .map(|docs_line| {
                             proc_macro2::TokenStream::from_str(&format!(
-                                "#[doc = r#\"{}\"#]",
-                                docs_line
+                                "#[doc = r#\"{docs_line}\"#]"
                             ))
                             .unwrap()
                         })
@@ -53,8 +52,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
                     docs.iter()
                         .map(|docs_line| {
                             proc_macro2::TokenStream::from_str(&format!(
-                                "#[doc = r#\"{}\"#]",
-                                docs_line
+                                "#[doc = r#\"{docs_line}\"#]"
                             ))
                             .unwrap()
                         })
@@ -164,8 +162,7 @@ pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream {
         quote! {<'info>}
     };
     let struct_doc = proc_macro2::TokenStream::from_str(&format!(
-        "#[doc = \" Generated CPI struct of the accounts for [`{}`].\"]",
-        name
+        "#[doc = \" Generated CPI struct of the accounts for [`{name}`].\"]"
     ))
     .unwrap();
     quote! {

+ 1 - 2
lang/syn/src/codegen/accounts/constraints.rs

@@ -314,8 +314,7 @@ pub fn generate_constraint_literal(
         let lit = &c.lit;
         let constraint = lit.value().replace('\"', "");
         let message = format!(
-            "Deprecated. Should be used with constraint: #[account(constraint = {})]",
-            constraint,
+            "Deprecated. Should be used with constraint: #[account(constraint = {constraint})]",
         );
         lit.span().warning(message).emit_as_item_tokens();
         constraint.parse().unwrap()

+ 1 - 1
lang/syn/src/codegen/program/common.rs

@@ -11,7 +11,7 @@ pub const SIGHASH_GLOBAL_NAMESPACE: &str = "global";
 // However, we do namespace methods in the preeimage so that we can use
 // different traits with the same method name.
 pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {
-    let preimage = format!("{}:{}", namespace, name);
+    let preimage = format!("{namespace}:{name}");
 
     let mut sighash = [0u8; 8];
     sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);

+ 1 - 1
lang/syn/src/codegen/program/cpi.rs

@@ -17,7 +17,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                 let name = &ix.raw_method.sig.ident.to_string();
                 let sighash_arr = sighash(SIGHASH_GLOBAL_NAMESPACE, name);
                 let sighash_tts: proc_macro2::TokenStream =
-                    format!("{:?}", sighash_arr).parse().unwrap();
+                    format!("{sighash_arr:?}").parse().unwrap();
                 let ret_type = &ix.returns.ty.to_token_stream();
                 let (method_ret, maybe_return) = match ret_type.to_string().as_str() {
                     "()" => (quote! {anchor_lang::Result<()> }, quote! { Ok(()) }),

+ 1 - 1
lang/syn/src/codegen/program/handlers.rs

@@ -100,7 +100,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
             let ix_method_name = &ix.raw_method.sig.ident;
             let anchor = &ix.anchor_ident;
             let variant_arm = generate_ix_variant(ix.raw_method.sig.ident.to_string(), &ix.args);
-            let ix_name_log = format!("Instruction: {}", ix_name);
+            let ix_name_log = format!("Instruction: {ix_name}");
             let ret_type = &ix.returns.ty.to_token_stream();
             let maybe_set_return_data = match ret_type.to_string().as_str() {
                 "()" => quote! {},

+ 1 - 1
lang/syn/src/codegen/program/instruction.rs

@@ -24,7 +24,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
             let ix_data_trait = {
                 let sighash_arr = sighash(SIGHASH_GLOBAL_NAMESPACE, name);
                 let sighash_tts: proc_macro2::TokenStream =
-                    format!("{:?}", sighash_arr).parse().unwrap();
+                    format!("{sighash_arr:?}").parse().unwrap();
                 quote! {
                     impl anchor_lang::Discriminator for #ix_name_camel {
                         const DISCRIMINATOR: [u8; 8] = #sighash_tts;

+ 3 - 3
lang/syn/src/idl/pda.rs

@@ -119,7 +119,7 @@ impl<'a> PdaParser<'a> {
                 } else if self.is_str_literal(&seed_path) {
                     self.parse_str_literal(&seed_path)
                 } else {
-                    println!("WARNING: unexpected seed category for var: {:?}", seed_path);
+                    println!("WARNING: unexpected seed category for var: {seed_path:?}");
                     None
                 }
             }
@@ -137,7 +137,7 @@ impl<'a> PdaParser<'a> {
             }
             // Unknown type. Please file an issue.
             _ => {
-                println!("WARNING: unexpected seed: {:?}", seed);
+                println!("WARNING: unexpected seed: {seed:?}");
                 None
             }
         }
@@ -305,7 +305,7 @@ fn parse_seed_path(seed: &Expr) -> Option<SeedPath> {
     // Break up the seed into each sub field component.
     let mut components: Vec<&str> = seed_str.split(" . ").collect();
     if components.len() <= 1 {
-        println!("WARNING: seeds are in an unexpected format: {:?}", seed);
+        println!("WARNING: seeds are in an unexpected format: {seed:?}");
         return None;
     }
 

+ 1 - 1
lang/syn/src/idl/relations.rs

@@ -11,7 +11,7 @@ pub fn parse(acc: &Field, seeds_feature: bool) -> Vec<String> {
         .flat_map(|s| match &s.join_target {
             Expr::Path(path) => path.path.segments.first().map(|l| l.ident.to_string()),
             _ => {
-                println!("WARNING: unexpected seed: {:?}", s);
+                println!("WARNING: unexpected seed: {s:?}");
                 None
             }
         })

+ 6 - 6
lang/syn/src/parser/accounts/mod.rs

@@ -44,17 +44,17 @@ fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> {
     let message = |constraint: &str, field: &str, required: bool| {
         if required {
             format! {
-                "a non-optional {} constraint requires \
-                a non-optional {} field to exist in the account \
+                "a non-optional {constraint} constraint requires \
+                a non-optional {field} field to exist in the account \
                 validation struct. Use the Program type to add \
-                the {} field to your validation struct.", constraint, field, field
+                the {field} field to your validation struct."
             }
         } else {
             format! {
-                "an optional {} constraint requires \
-                an optional or required {} field to exist \
+                "an optional {constraint} constraint requires \
+                an optional or required {field} field to exist \
                 in the account validation struct. Use the Program type \
-                to add the {} field to your validation struct.", constraint, field, field
+                to add the {field} field to your validation struct."
             }
         }
     };

+ 25 - 34
spl/src/token.rs

@@ -9,8 +9,8 @@ use std::ops::Deref;
 pub use spl_token;
 pub use spl_token::ID;
 
-pub fn transfer<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Transfer<'info>>,
+pub fn transfer<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, Transfer<'info>>,
     amount: u64,
 ) -> Result<()> {
     let ix = spl_token::instruction::transfer(
@@ -33,8 +33,8 @@ pub fn transfer<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn transfer_checked<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, TransferChecked<'info>>,
+pub fn transfer_checked<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, TransferChecked<'info>>,
     amount: u64,
     decimals: u8,
 ) -> Result<()> {
@@ -61,8 +61,8 @@ pub fn transfer_checked<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn mint_to<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, MintTo<'info>>,
+pub fn mint_to<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, MintTo<'info>>,
     amount: u64,
 ) -> Result<()> {
     let ix = spl_token::instruction::mint_to(
@@ -85,10 +85,7 @@ pub fn mint_to<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn burn<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Burn<'info>>,
-    amount: u64,
-) -> Result<()> {
+pub fn burn<'info>(ctx: CpiContext<'_, '_, '_, 'info, Burn<'info>>, amount: u64) -> Result<()> {
     let ix = spl_token::instruction::burn(
         &spl_token::ID,
         ctx.accounts.from.key,
@@ -109,8 +106,8 @@ pub fn burn<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn approve<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, Approve<'info>>,
+pub fn approve<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, Approve<'info>>,
     amount: u64,
 ) -> Result<()> {
     let ix = spl_token::instruction::approve(
@@ -133,7 +130,7 @@ pub fn approve<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn revoke<'a, 'b, 'c, 'info>(ctx: CpiContext<'a, 'b, 'c, 'info, Revoke<'info>>) -> Result<()> {
+pub fn revoke<'info>(ctx: CpiContext<'_, '_, '_, 'info, Revoke<'info>>) -> Result<()> {
     let ix = spl_token::instruction::revoke(
         &spl_token::ID,
         ctx.accounts.source.key,
@@ -148,8 +145,8 @@ pub fn revoke<'a, 'b, 'c, 'info>(ctx: CpiContext<'a, 'b, 'c, 'info, Revoke<'info
     .map_err(Into::into)
 }
 
-pub fn initialize_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, InitializeAccount<'info>>,
+pub fn initialize_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, InitializeAccount<'info>>,
 ) -> Result<()> {
     let ix = spl_token::instruction::initialize_account(
         &spl_token::ID,
@@ -170,8 +167,8 @@ pub fn initialize_account<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn initialize_account3<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, InitializeAccount3<'info>>,
+pub fn initialize_account3<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, InitializeAccount3<'info>>,
 ) -> Result<()> {
     let ix = spl_token::instruction::initialize_account3(
         &spl_token::ID,
@@ -187,9 +184,7 @@ pub fn initialize_account3<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn close_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, CloseAccount<'info>>,
-) -> Result<()> {
+pub fn close_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, CloseAccount<'info>>) -> Result<()> {
     let ix = spl_token::instruction::close_account(
         &spl_token::ID,
         ctx.accounts.account.key,
@@ -209,8 +204,8 @@ pub fn close_account<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn freeze_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, FreezeAccount<'info>>,
+pub fn freeze_account<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, FreezeAccount<'info>>,
 ) -> Result<()> {
     let ix = spl_token::instruction::freeze_account(
         &spl_token::ID,
@@ -231,9 +226,7 @@ pub fn freeze_account<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn thaw_account<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, ThawAccount<'info>>,
-) -> Result<()> {
+pub fn thaw_account<'info>(ctx: CpiContext<'_, '_, '_, 'info, ThawAccount<'info>>) -> Result<()> {
     let ix = spl_token::instruction::thaw_account(
         &spl_token::ID,
         ctx.accounts.account.key,
@@ -253,8 +246,8 @@ pub fn thaw_account<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn initialize_mint<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, InitializeMint<'info>>,
+pub fn initialize_mint<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, InitializeMint<'info>>,
     decimals: u8,
     authority: &Pubkey,
     freeze_authority: Option<&Pubkey>,
@@ -274,8 +267,8 @@ pub fn initialize_mint<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn initialize_mint2<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, InitializeMint2<'info>>,
+pub fn initialize_mint2<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, InitializeMint2<'info>>,
     decimals: u8,
     authority: &Pubkey,
     freeze_authority: Option<&Pubkey>,
@@ -291,8 +284,8 @@ pub fn initialize_mint2<'a, 'b, 'c, 'info>(
         .map_err(Into::into)
 }
 
-pub fn set_authority<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, SetAuthority<'info>>,
+pub fn set_authority<'info>(
+    ctx: CpiContext<'_, '_, '_, 'info, SetAuthority<'info>>,
     authority_type: spl_token::instruction::AuthorityType,
     new_authority: Option<Pubkey>,
 ) -> Result<()> {
@@ -320,9 +313,7 @@ pub fn set_authority<'a, 'b, 'c, 'info>(
     .map_err(Into::into)
 }
 
-pub fn sync_native<'a, 'b, 'c, 'info>(
-    ctx: CpiContext<'a, 'b, 'c, 'info, SyncNative<'info>>,
-) -> Result<()> {
+pub fn sync_native<'info>(ctx: CpiContext<'_, '_, '_, 'info, SyncNative<'info>>) -> Result<()> {
     let ix = spl_token::instruction::sync_native(&spl_token::ID, ctx.accounts.account.key)?;
     solana_program::program::invoke_signed(&ix, &[ctx.accounts.account.clone()], ctx.signer_seeds)
         .map_err(Into::into)