From 7392badc809e34a7783412ecc5ef7bd7c9753ed5 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 14 Sep 2023 00:39:57 +0000 Subject: [PATCH] code style --- .../phactory/src/contracts/support/keeper.rs | 1 + crates/phactory/src/lib.rs | 30 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/crates/phactory/src/contracts/support/keeper.rs b/crates/phactory/src/contracts/support/keeper.rs index aef4cdd38e..e978709f95 100644 --- a/crates/phactory/src/contracts/support/keeper.rs +++ b/crates/phactory/src/contracts/support/keeper.rs @@ -46,6 +46,7 @@ impl ContractsKeeper { } pub fn drain(&mut self) -> impl Iterator { + #[allow(clippy::iter_kv_map)] std::mem::take(&mut self.contracts) .into_iter() .map(|(_, v)| v) diff --git a/crates/phactory/src/lib.rs b/crates/phactory/src/lib.rs index 9d730c4271..3df04d650c 100644 --- a/crates/phactory/src/lib.rs +++ b/crates/phactory/src/lib.rs @@ -561,7 +561,7 @@ impl Phactory let file = File::create(&checkpoint_file).context("Failed to create checkpoint file")?; self.take_checkpoint_to_writer(&key, file) .context("Take checkpoint to writer failed")?; - info!("Checkpoint saved to {}", checkpoint_file); + info!("Checkpoint saved to {checkpoint_file}"); self.last_checkpoint = Instant::now(); remove_outdated_checkpoints( &self.args.storage_path, @@ -618,43 +618,33 @@ impl Phactory Ok(file) => file, Err(err) if matches!(err.kind(), ErrorKind::NotFound) => { // This should never happen unless it was removed just after the glob. - anyhow::bail!("Checkpoint file {:?} is not found", ckpt_filename); + anyhow::bail!("Checkpoint file {ckpt_filename:?} is not found"); } Err(err) => { - error!( - "Failed to open checkpoint file {:?}: {:?}", - ckpt_filename, err - ); + error!("Failed to open checkpoint file {ckpt_filename:?}: {err:?}",); if args.remove_corrupted_checkpoint { - error!("Removing {:?}", ckpt_filename); + error!("Removing {ckpt_filename:?}"); std::fs::remove_file(ckpt_filename) .context("Failed to remove corrupted checkpoint file")?; } - anyhow::bail!( - "Failed to open checkpoint file {:?}: {:?}", - ckpt_filename, - err - ); + anyhow::bail!("Failed to open checkpoint file {ckpt_filename:?}: {err:?}"); } }; - info!("Loading checkpoint from file {:?}", ckpt_filename); + info!("Loading checkpoint from file {ckpt_filename:?}"); match Self::restore_from_checkpoint_reader(&runtime_data.sk, file, args) { Ok(state) => { - info!("Succeeded to load checkpoint file {:?}", ckpt_filename); + info!("Succeeded to load checkpoint file {ckpt_filename:?}"); Ok(Some(state)) } - Err(err /*Don't leak it into the log*/) => { - error!( - "Failed to load checkpoint file {:?}: {err:?}", - ckpt_filename - ); + Err(_err /*Don't leak it into the log*/) => { + error!("Failed to load checkpoint file {ckpt_filename:?}"); if args.remove_corrupted_checkpoint { error!("Removing {:?}", ckpt_filename); std::fs::remove_file(ckpt_filename) .context("Failed to remove corrupted checkpoint file")?; } - anyhow::bail!("Failed to load checkpoint file {:?}", ckpt_filename); + anyhow::bail!("Failed to load checkpoint file {ckpt_filename:?}"); } } }