From c98b9c736e3fc938e61a76012176b168be78dbe0 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 24 Aug 2023 13:36:12 -0400 Subject: [PATCH] rust: appease clippy and fmt with after new Rust release (#899) --- cmd/crates/soroban-spec-json/src/lib.rs | 1 + cmd/soroban-cli/src/commands/contract/invoke.rs | 2 +- cmd/soroban-cli/src/commands/version.rs | 2 +- cmd/soroban-cli/src/log/event.rs | 2 +- cmd/soroban-cli/src/utils.rs | 6 +++--- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/crates/soroban-spec-json/src/lib.rs b/cmd/crates/soroban-spec-json/src/lib.rs index 9394f33db..8626262b8 100644 --- a/cmd/crates/soroban-spec-json/src/lib.rs +++ b/cmd/crates/soroban-spec-json/src/lib.rs @@ -55,6 +55,7 @@ pub fn generate_from_wasm(wasm: &[u8]) -> Result { Ok(json) } +/// # Panics pub fn generate(spec: &[ScSpecEntry]) -> String { let collected: Vec<_> = spec.iter().map(Entry::from).collect(); serde_json::to_string_pretty(&collected).expect("serialization of the spec entries should not have any failure cases as all keys are strings and the serialize implementations are derived") diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index daea261ed..49f75bf66 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -547,7 +547,7 @@ fn build_custom_cmd(name: &str, spec: &Spec) -> Result { let long_doc: &'static str = Box::leak(arg_file_help(doc).into_boxed_str()); cmd = cmd.about(Some(doc)).long_about(long_doc); - for (name, type_) in inputs_map.iter() { + for (name, type_) in inputs_map { let mut arg = clap::Arg::new(name); let file_arg_name = fmt_arg_file_name(name); let mut file_arg = clap::Arg::new(&file_arg_name); diff --git a/cmd/soroban-cli/src/commands/version.rs b/cmd/soroban-cli/src/commands/version.rs index 44848322c..21be0743a 100644 --- a/cmd/soroban-cli/src/commands/version.rs +++ b/cmd/soroban-cli/src/commands/version.rs @@ -22,7 +22,7 @@ pub fn short() -> String { pub fn long() -> String { let env = soroban_env_host::VERSION; let xdr = soroban_env_host::VERSION.xdr; - vec![ + [ short(), format!("soroban-env {} ({})", env.pkg, env.rev), format!("soroban-env interface version {}", meta::INTERFACE_VERSION), diff --git a/cmd/soroban-cli/src/log/event.rs b/cmd/soroban-cli/src/log/event.rs index acd92fee5..33d150ca0 100644 --- a/cmd/soroban-cli/src/log/event.rs +++ b/cmd/soroban-cli/src/log/event.rs @@ -1,7 +1,7 @@ use soroban_env_host::events::HostEvent; pub fn events(events: &[HostEvent]) { - for event in events.iter() { + for event in events { tracing::info!(log = event.to_string()); } } diff --git a/cmd/soroban-cli/src/utils.rs b/cmd/soroban-cli/src/utils.rs index d2b3705b1..fea858ba3 100644 --- a/cmd/soroban-cli/src/utils.rs +++ b/cmd/soroban-cli/src/utils.rs @@ -84,7 +84,7 @@ pub fn add_contract_code_to_ledger_entries( }), ext: LedgerEntryExt::V0, }; - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if **k == code_key { **e = code_entry; return Ok(hash); @@ -125,7 +125,7 @@ pub fn add_contract_to_ledger_entries( }), ext: LedgerEntryExt::V0, }; - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if **k == contract_key { **e = contract_entry; return; @@ -143,7 +143,7 @@ pub fn bump_ledger_entry_expirations( .iter() .map(|b| (b.key.as_ref().clone(), b.min_expiration)) .collect::>(); - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if let Some(min_expiration) = lookup.get(k.as_ref()) { if let LedgerEntryData::ContractData(entry) = &mut e.data { entry.expiration_ledger_seq = *min_expiration;