diff --git a/rust/c509-certificate/examples/cli/main.rs b/rust/c509-certificate/examples/cli/main.rs index e63d9e5f8cd..0f48f58a6a7 100644 --- a/rust/c509-certificate/examples/cli/main.rs +++ b/rust/c509-certificate/examples/cli/main.rs @@ -364,7 +364,7 @@ fn time_to_string(time: u64) -> anyhow::Result { // Attempt to convert the timestamp and handle errors if they occur let timestamp: i64 = time .try_into() - .map_err(|e| anyhow::anyhow!("Failed to convert time: {:?}", e))?; + .map_err(|e| anyhow::anyhow!("Failed to convert time: {e:?}"))?; // Convert the timestamp to a DateTime and handle any potential errors let datetime = DateTime::from_timestamp(timestamp, 0) diff --git a/rust/cardano-blockchain-types/src/auxdata/scripts.rs b/rust/cardano-blockchain-types/src/auxdata/scripts.rs index d82b30d397b..751ff06d942 100644 --- a/rust/cardano-blockchain-types/src/auxdata/scripts.rs +++ b/rust/cardano-blockchain-types/src/auxdata/scripts.rs @@ -100,7 +100,7 @@ impl TryFrom for ScriptType { fn try_from(value: u64) -> Result { match value { - 0 => Err(anyhow!("Invalid script type: {}", value)), + 0 => Err(anyhow!("Invalid script type: {value}")), 1 => Ok(Self::Native), _ => Ok(Self::Plutus(value.saturating_sub(1))), } diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs index ec2456e7b64..883f3c0b3d0 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs @@ -239,7 +239,7 @@ impl MithrilSnapshotConfig { let Ok(relative_file) = tmp_file.strip_prefix(&tmp_path) else { error!("Failed to get relative path of file."); - bail!("Failed to strip prefix: {tmp_path:?}"); + bail!("Failed to strip prefix: {}", tmp_path.to_string_lossy()); }; // IF we make it here, the files are identical, so we can de-dup them safely. @@ -247,11 +247,10 @@ impl MithrilSnapshotConfig { if tmp_file.exists() { if let Err(error) = std::fs::remove_file(tmp_file) { error!( - "Error removing tmp file {} : {}", + "Error removing tmp file {} : {error}", tmp_file.to_string_lossy(), - error ); - bail!("Failed to remove tmp file: {tmp_file:?}"); + bail!("Failed to remove tmp file: {}", tmp_file.to_string_lossy()); } } @@ -260,21 +259,23 @@ impl MithrilSnapshotConfig { // Hardlink the src file to the tmp file. if let Some(parent) = tmp_file.parent() { if let Err(error) = std::fs::create_dir_all(parent) { - error!("Error creating parent dir {parent:?} for tmp file {tmp_file:?}: {error}"); + error!( + "Error creating parent dir {parent:?} for tmp file {}: {error}", + tmp_file.to_string_lossy() + ); } } if let Err(error) = std::fs::hard_link(src_file, tmp_file) { error!( - "Error linking src file {} to tmp file {} : {}", + "Error linking src file {} to tmp file {} : {error}", src_file.to_string_lossy(), tmp_file.to_string_lossy(), - error ); - bail!("Failed to link src file: {src_file:?}"); + bail!("Failed to link src file: {}", src_file.to_string_lossy()); } // And if we made it here, file was successfully de-duped. YAY. - debug!("DeDup OK: {tmp_file:?}"); + debug!("DeDup OK: {tmp_file:?}",); Ok(()) } diff --git a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs index 52fdfdd9051..b1e72f19340 100644 --- a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs +++ b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs @@ -397,7 +397,7 @@ impl FileDownloader for MithrilTurboDownloader { // We only support full downloads for now. if !matches!(download_event_type, DownloadEvent::Full { .. }) { - bail!("Unsupported Download Event Type: {:?}", download_event_type); + bail!("Unsupported Download Event Type: {download_event_type:?}"); } let location = location.as_str(); diff --git a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs index 7ab5b64e4f8..dd68fd882d6 100644 --- a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs +++ b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs @@ -417,10 +417,7 @@ impl ParallelDownloadProcessor { chain: Network, ) -> Result { if cfg.chunk_size < MIN_CHUNK_SIZE { - bail!( - "Download chunk size must be at least {} bytes", - MIN_CHUNK_SIZE - ); + bail!("Download chunk size must be at least {MIN_CHUNK_SIZE} bytes"); } let file_size = get_content_length_async(url).await?; @@ -595,7 +592,7 @@ impl ParallelDownloadProcessor { let queue = worker_queue.value(); queue.send(order)?; } else { - bail!("Expected a work queue for worker: {:?}", this_worker); + bail!("Expected a work queue for worker: {this_worker:?}"); } } else { // No more work, so remove the work queue from the map. @@ -779,7 +776,7 @@ async fn get_content_length_async(url: &str) -> Result { Ok(result) => result, Err(error) => { error!("get_content_length failed"); - Err(anyhow::anyhow!("get_content_length failed: {}", error)) + Err(anyhow::anyhow!("get_content_length failed: {error}")) }, } } @@ -799,8 +796,7 @@ fn get_content_length(url: &str) -> Result { if let Some(accept_ranges) = response.header(ACCEPT_RANGES.as_str()) { if accept_ranges != "bytes" { bail!( - "Server doesn't support HTTP range byte requests (Accept-Ranges = {})", - accept_ranges + "Server doesn't support HTTP range byte requests (Accept-Ranges = {accept_ranges})", ); } } else { diff --git a/rust/immutable-ledger/src/serialize.rs b/rust/immutable-ledger/src/serialize.rs index d8640d2bc4c..795e196ffa8 100644 --- a/rust/immutable-ledger/src/serialize.rs +++ b/rust/immutable-ledger/src/serialize.rs @@ -437,7 +437,7 @@ impl BlockHeader { let prev_block_hash_type = match hash_function.as_u64() { BLAKE3_CBOR_TAG => HashFunction::Blake3, BLAKE_2B_CBOR_TAG => HashFunction::Blake2b, - _ => bail!(format!("Invalid hash function type {:?}", hash_function)), + _ => bail!(format!("Invalid hash function type {hash_function:?}")), }; let prev_block_hash = cbor_decoder diff --git a/rust/signed_doc/src/metadata/mod.rs b/rust/signed_doc/src/metadata/mod.rs index a90a5acd7ce..289070a843a 100644 --- a/rust/signed_doc/src/metadata/mod.rs +++ b/rust/signed_doc/src/metadata/mod.rs @@ -190,7 +190,7 @@ impl Metadata { let fields = serde::Deserializer::deserialize_map(fields, MetadataDeserializeVisitor)?; let report = ProblemReport::new("Deserializing metadata from json"); let metadata = Self::from_fields(fields.into_iter().map(anyhow::Result::<_>::Ok), &report)?; - anyhow::ensure!(!report.is_problematic(), "{:?}", report); + anyhow::ensure!(!report.is_problematic(), "{report:?}"); Ok(metadata) } diff --git a/rust/signed_doc/src/validator/rules/content_type.rs b/rust/signed_doc/src/validator/rules/content_type.rs index 2af5db4f164..4806f6bdbf3 100644 --- a/rust/signed_doc/src/validator/rules/content_type.rs +++ b/rust/signed_doc/src/validator/rules/content_type.rs @@ -106,7 +106,7 @@ impl ContentTypeRule { ContentType::Json => { if let Err(e) = serde_json::from_slice::<&serde_json::value::RawValue>(content) { - anyhow::bail!("Invalid {} content: {e}", exp) + anyhow::bail!("Invalid {exp} content: {e}") } }, ContentType::Cbor => { @@ -129,7 +129,7 @@ impl ContentTypeRule { | ContentType::Plain | ContentType::PlainHandlebars => { // TODO: not implemented yet - anyhow::bail!("`{}` is valid but unavailable yet", exp) + anyhow::bail!("`{exp}` is valid but unavailable yet") }, } }