From b7ef60b899d3043921f0fb6ee7204b4d7eae7bf5 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:29:19 -0500 Subject: [PATCH] Enable clippy's uninlined_format_args linter (#7204) Co-authored-by: Matthias Seitz --- Cargo.toml | 1 + bin/reth/src/cli/mod.rs | 6 +-- bin/reth/src/commands/db/get.rs | 4 +- bin/reth/src/commands/import.rs | 2 +- crates/net/eth-wire/src/ethstream.rs | 2 +- crates/net/network/src/transactions/mod.rs | 2 +- .../network/tests/it/big_pooled_txs_req.rs | 2 +- crates/net/network/tests/it/startup.rs | 2 +- crates/node-builder/src/builder.rs | 2 +- crates/node-core/src/dirs.rs | 12 ++--- crates/primitives/benches/integer_list.rs | 2 +- crates/primitives/benches/validate_blob_tx.rs | 4 +- crates/primitives/src/chain/spec.rs | 30 +++++-------- crates/primitives/src/compression/mod.rs | 2 +- crates/primitives/src/integer_list.rs | 2 +- crates/primitives/src/transaction/tx_type.rs | 18 +++----- crates/rpc/rpc-builder/tests/it/http.rs | 4 +- crates/rpc/rpc-testing-util/src/debug.rs | 2 +- crates/rpc/rpc-testing-util/src/trace.rs | 45 +++++++++---------- crates/rpc/rpc-testing-util/src/utils.rs | 2 +- crates/rpc/rpc-testing-util/tests/it/trace.rs | 8 ++-- crates/storage/db/src/lib.rs | 2 +- crates/storage/db/src/tables/mod.rs | 2 +- crates/storage/provider/src/chain.rs | 4 +- crates/transaction-pool/benches/priority.rs | 4 +- crates/transaction-pool/src/blobstore/disk.rs | 2 +- crates/transaction-pool/src/pool/blob.rs | 3 +- crates/transaction-pool/src/pool/parked.rs | 3 +- crates/transaction-pool/src/pool/txpool.rs | 4 +- testing/ef-tests/src/models.rs | 8 ++-- testing/ef-tests/src/suite.rs | 2 +- 31 files changed, 84 insertions(+), 104 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f315e33a6..2e918447d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,6 +90,7 @@ rust.rust_2018_idioms = "deny" clippy.empty_line_after_outer_attr = "deny" clippy.derive_partial_eq_without_eq = "deny" clippy.trait_duplication_in_bounds = "deny" +clippy.uninlined_format_args = "warn" [workspace.package] version = "0.2.0-beta.3" diff --git a/bin/reth/src/cli/mod.rs b/bin/reth/src/cli/mod.rs index abe6345fe..ff206eefc 100644 --- a/bin/reth/src/cli/mod.rs +++ b/bin/reth/src/cli/mod.rs @@ -244,7 +244,7 @@ mod tests { reth.logs.log_file_directory.join(reth.chain.chain.to_string()); let log_dir = reth.logs.log_file_directory; let end = format!("reth/logs/{}", SUPPORTED_CHAINS[0]); - assert!(log_dir.as_ref().ends_with(end), "{:?}", log_dir); + assert!(log_dir.as_ref().ends_with(end), "{log_dir:?}"); let mut iter = SUPPORTED_CHAINS.iter(); iter.next(); @@ -253,8 +253,8 @@ mod tests { reth.logs.log_file_directory = reth.logs.log_file_directory.join(reth.chain.chain.to_string()); let log_dir = reth.logs.log_file_directory; - let end = format!("reth/logs/{}", chain); - assert!(log_dir.as_ref().ends_with(end), "{:?}", log_dir); + let end = format!("reth/logs/{chain}"); + assert!(log_dir.as_ref().ends_with(end), "{log_dir:?}"); } } diff --git a/bin/reth/src/commands/db/get.rs b/bin/reth/src/commands/db/get.rs index 57672ee4c..958ced09f 100644 --- a/bin/reth/src/commands/db/get.rs +++ b/bin/reth/src/commands/db/get.rs @@ -85,7 +85,7 @@ impl Command { match content { Some(content) => { if raw { - println!("{:?}", content); + println!("{content:?}"); } else { match segment { StaticFileSegment::Headers => { @@ -157,7 +157,7 @@ impl TableViewer<()> for GetValueViewer<'_, DB> { match content { Some(content) => { - println!("{}", content); + println!("{content}"); } None => { error!(target: "reth::cli", "No content for the given table key."); diff --git a/bin/reth/src/commands/import.rs b/bin/reth/src/commands/import.rs index 81b50dd8a..264e86965 100644 --- a/bin/reth/src/commands/import.rs +++ b/bin/reth/src/commands/import.rs @@ -221,7 +221,7 @@ impl ImportCommand { /// Loads the reth config fn load_config(&self, config_path: PathBuf) -> eyre::Result { confy::load_path::(config_path.clone()) - .wrap_err_with(|| format!("Could not load config file {:?}", config_path)) + .wrap_err_with(|| format!("Could not load config file {config_path:?}")) } } diff --git a/crates/net/eth-wire/src/ethstream.rs b/crates/net/eth-wire/src/ethstream.rs index 82184ec94..7ee68c1b5 100644 --- a/crates/net/eth-wire/src/ethstream.rs +++ b/crates/net/eth-wire/src/ethstream.rs @@ -247,7 +247,7 @@ where let msg = if bytes.len() > 50 { format!("{:02x?}...{:x?}", &bytes[..10], &bytes[bytes.len() - 10..]) } else { - format!("{:02x?}", bytes) + format!("{bytes:02x?}") }; debug!( version=?this.version, diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 9467f2aef..28621726d 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -2006,7 +2006,7 @@ mod tests { assert_eq!(transactions.len(), 1); } Err(e) => { - panic!("error: {:?}", e); + panic!("error: {e:?}"); } } } diff --git a/crates/net/network/tests/it/big_pooled_txs_req.rs b/crates/net/network/tests/it/big_pooled_txs_req.rs index e5b639eee..5b3a2a0d0 100644 --- a/crates/net/network/tests/it/big_pooled_txs_req.rs +++ b/crates/net/network/tests/it/big_pooled_txs_req.rs @@ -82,7 +82,7 @@ async fn test_large_tx_req() { txs.into_iter().for_each(|tx| assert!(txs_hashes.contains(tx.hash()))); } Err(e) => { - panic!("error: {:?}", e); + panic!("error: {e:?}"); } } } diff --git a/crates/net/network/tests/it/startup.rs b/crates/net/network/tests/it/startup.rs index 774c6c0af..ca9d7c61a 100644 --- a/crates/net/network/tests/it/startup.rs +++ b/crates/net/network/tests/it/startup.rs @@ -48,7 +48,7 @@ async fn test_listener_addr_in_use() { let addr = config.listener_addr; let result = NetworkManager::new(config).await; let err = result.err().unwrap(); - assert!(is_addr_in_use_kind(&err, ServiceKind::Listener(addr)), "{:?}", err); + assert!(is_addr_in_use_kind(&err, ServiceKind::Listener(addr)), "{err:?}"); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/node-builder/src/builder.rs b/crates/node-builder/src/builder.rs index 94b1f2692..02596aabd 100644 --- a/crates/node-builder/src/builder.rs +++ b/crates/node-builder/src/builder.rs @@ -154,7 +154,7 @@ impl NodeBuilder { let config_path = self.config.config.clone().unwrap_or_else(|| data_dir.config_path()); let mut config = confy::load_path::(&config_path) - .wrap_err_with(|| format!("Could not load config file {:?}", config_path))?; + .wrap_err_with(|| format!("Could not load config file {config_path:?}"))?; info!(target: "reth::cli", path = ?config_path, "Configuration loaded"); diff --git a/crates/node-core/src/dirs.rs b/crates/node-core/src/dirs.rs index 3559b161c..223e65bb2 100644 --- a/crates/node-core/src/dirs.rs +++ b/crates/node-core/src/dirs.rs @@ -357,28 +357,28 @@ mod tests { fn test_maybe_data_dir_path() { let path = MaybePlatformPath::::default(); let path = path.unwrap_or_chain_default(Chain::mainnet()); - assert!(path.as_ref().ends_with("reth/mainnet"), "{:?}", path); + assert!(path.as_ref().ends_with("reth/mainnet"), "{path:?}"); let db_path = path.db_path(); - assert!(db_path.ends_with("reth/mainnet/db"), "{:?}", db_path); + assert!(db_path.ends_with("reth/mainnet/db"), "{db_path:?}"); let path = MaybePlatformPath::::from_str("my/path/to/datadir").unwrap(); let path = path.unwrap_or_chain_default(Chain::mainnet()); - assert!(path.as_ref().ends_with("my/path/to/datadir"), "{:?}", path); + assert!(path.as_ref().ends_with("my/path/to/datadir"), "{path:?}"); } #[test] fn test_maybe_testnet_datadir_path() { let path = MaybePlatformPath::::default(); let path = path.unwrap_or_chain_default(Chain::goerli()); - assert!(path.as_ref().ends_with("reth/goerli"), "{:?}", path); + assert!(path.as_ref().ends_with("reth/goerli"), "{path:?}"); let path = MaybePlatformPath::::default(); let path = path.unwrap_or_chain_default(Chain::holesky()); - assert!(path.as_ref().ends_with("reth/holesky"), "{:?}", path); + assert!(path.as_ref().ends_with("reth/holesky"), "{path:?}"); let path = MaybePlatformPath::::default(); let path = path.unwrap_or_chain_default(Chain::sepolia()); - assert!(path.as_ref().ends_with("reth/sepolia"), "{:?}", path); + assert!(path.as_ref().ends_with("reth/sepolia"), "{path:?}"); } } diff --git a/crates/primitives/benches/integer_list.rs b/crates/primitives/benches/integer_list.rs index c07dbaa9d..3945d48c9 100644 --- a/crates/primitives/benches/integer_list.rs +++ b/crates/primitives/benches/integer_list.rs @@ -106,7 +106,7 @@ mod elias_fano { impl fmt::Debug for IntegerList { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let vec: Vec = self.0.iter(0).collect(); - write!(f, "IntegerList {:?}", vec) + write!(f, "IntegerList {vec:?}") } } diff --git a/crates/primitives/benches/validate_blob_tx.rs b/crates/primitives/benches/validate_blob_tx.rs index 1f0db472f..0bc2f04c6 100644 --- a/crates/primitives/benches/validate_blob_tx.rs +++ b/crates/primitives/benches/validate_blob_tx.rs @@ -73,13 +73,13 @@ fn validate_blob_tx( (tx, blob_sidecar) }; - let group_id = format!("validate_blob | num blobs: {} | {}", num_blobs, description,); + let group_id = format!("validate_blob | num blobs: {num_blobs} | {description}"); // for now we just use the default SubPoolLimit group.bench_function(group_id, |b| { b.iter_with_setup(setup, |(tx, blob_sidecar)| { if let Err(err) = std::hint::black_box(tx.validate_blob(&blob_sidecar, &kzg_settings)) { - println!("Validation failed: {:?}", err); + println!("Validation failed: {err:?}"); } }); }); diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 10e9094fd..c53af6168 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -1451,7 +1451,7 @@ impl Display for DisplayFork { match self.activated_at { ForkCondition::Block(at) | ForkCondition::Timestamp(at) => { - write!(f, "{:32} @{}", name_with_eip, at)?; + write!(f, "{name_with_eip:32} @{at}")?; } ForkCondition::TTD { fork_block, total_difficulty } => { write!( @@ -1523,10 +1523,10 @@ impl Display for DisplayHardforks { next_is_empty: bool, f: &mut Formatter<'_>, ) -> std::fmt::Result { - writeln!(f, "{}:", header)?; + writeln!(f, "{header}:")?; let mut iter = forks.iter().peekable(); while let Some(fork) = iter.next() { - write!(f, "- {}", fork)?; + write!(f, "- {fork}")?; if !next_is_empty || iter.peek().is_some() { writeln!(f)?; } @@ -1628,15 +1628,13 @@ mod tests { if let Some(computed_id) = spec.hardfork_fork_id(*hardfork) { assert_eq!( expected_id, &computed_id, - "Expected fork ID {:?}, computed fork ID {:?} for hardfork {}", - expected_id, computed_id, hardfork + "Expected fork ID {expected_id:?}, computed fork ID {computed_id:?} for hardfork {hardfork}" ); if let Hardfork::Shanghai = hardfork { if let Some(shangai_id) = spec.shanghai_fork_id() { assert_eq!( expected_id, &shangai_id, - "Expected fork ID {:?}, computed fork ID {:?} for Shanghai hardfork", - expected_id, computed_id + "Expected fork ID {expected_id:?}, computed fork ID {computed_id:?} for Shanghai hardfork" ); } else { panic!("Expected ForkCondition to return Some for Hardfork::Shanghai"); @@ -1786,8 +1784,7 @@ Post-merge hard forks (timestamp based): let happy_path_expected = Head { number: 73, timestamp: 11313123, ..Default::default() }; assert_eq!( happy_path_head, happy_path_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - happy_path_expected, happy_path_head + "expected satisfy() to return {happy_path_expected:#?}, but got {happy_path_head:#?} " ); // multiple timestamp test case (i.e Shanghai -> Cancun) let multiple_timestamp_fork_case = ChainSpec::builder() @@ -1804,8 +1801,7 @@ Post-merge hard forks (timestamp based): Head { number: 73, timestamp: 11313398, ..Default::default() }; assert_eq!( multi_timestamp_head, mult_timestamp_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - mult_timestamp_expected, multi_timestamp_head + "expected satisfy() to return {mult_timestamp_expected:#?}, but got {multi_timestamp_head:#?} " ); // no ForkCondition::Block test case let no_block_fork_case = ChainSpec::builder() @@ -1817,8 +1813,7 @@ Post-merge hard forks (timestamp based): let no_block_fork_expected = Head { number: 0, timestamp: 11313123, ..Default::default() }; assert_eq!( no_block_fork_head, no_block_fork_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - no_block_fork_expected, no_block_fork_head + "expected satisfy() to return {no_block_fork_expected:#?}, but got {no_block_fork_head:#?} ", ); // spec w/ ForkCondition::TTD with block_num test case (Sepolia merge netsplit edge case) let fork_cond_ttd_blocknum_case = ChainSpec::builder() @@ -1841,8 +1836,7 @@ Post-merge hard forks (timestamp based): Head { number: 101, timestamp: 11313123, ..Default::default() }; assert_eq!( fork_cond_ttd_blocknum_head, fork_cond_ttd_blocknum_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - fork_cond_ttd_blocknum_expected, fork_cond_ttd_blocknum_head + "expected satisfy() to return {fork_cond_ttd_blocknum_expected:#?}, but got {fork_cond_ttd_blocknum_expected:#?} ", ); // spec w/ only ForkCondition::Block - test the match arm for ForkCondition::Block to ensure @@ -1858,8 +1852,7 @@ Post-merge hard forks (timestamp based): let fork_cond_block_only_expected = Head { number: 73, ..Default::default() }; assert_eq!( fork_cond_block_only_head, fork_cond_block_only_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - fork_cond_block_only_expected, fork_cond_block_only_head + "expected satisfy() to return {fork_cond_block_only_expected:#?}, but got {fork_cond_block_only_head:#?} ", ); // Fork::ConditionTTD test case without a new chain spec to demonstrate ChainSpec::satisfy // is independent of ChainSpec for this(these - including ForkCondition::Block) match arm(s) @@ -1871,8 +1864,7 @@ Post-merge hard forks (timestamp based): Head { total_difficulty: U256::from(10_790_000), ..Default::default() }; assert_eq!( fork_cond_ttd_no_new_spec, fork_cond_ttd_no_new_spec_expected, - "expected satisfy() to return {:#?}, but got {:#?} ", - fork_cond_ttd_no_new_spec_expected, fork_cond_ttd_no_new_spec + "expected satisfy() to return {fork_cond_ttd_blocknum_expected:#?}, but got {fork_cond_ttd_blocknum_expected:#?} ", ); } diff --git a/crates/primitives/src/compression/mod.rs b/crates/primitives/src/compression/mod.rs index dee4a8891..0f0ae7a6b 100644 --- a/crates/primitives/src/compression/mod.rs +++ b/crates/primitives/src/compression/mod.rs @@ -55,7 +55,7 @@ impl ReusableDecompressor { while let Err(err) = self.decompressor.decompress_to_buffer(src, &mut self.buf) { let err = err.to_string(); if !err.contains("Destination buffer is too small") { - panic!("Failed to decompress: {}", err); + panic!("Failed to decompress: {err}"); } self.buf.reserve(self.buf.capacity() + 24_000); } diff --git a/crates/primitives/src/integer_list.rs b/crates/primitives/src/integer_list.rs index f53ee41b3..edcf31086 100644 --- a/crates/primitives/src/integer_list.rs +++ b/crates/primitives/src/integer_list.rs @@ -23,7 +23,7 @@ impl Deref for IntegerList { impl fmt::Debug for IntegerList { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let vec: Vec = self.0.iter().collect(); - write!(f, "IntegerList {:?}", vec) + write!(f, "IntegerList {vec:?}") } } diff --git a/crates/primitives/src/transaction/tx_type.rs b/crates/primitives/src/transaction/tx_type.rs index 1bff62cd3..79179128b 100644 --- a/crates/primitives/src/transaction/tx_type.rs +++ b/crates/primitives/src/transaction/tx_type.rs @@ -142,10 +142,10 @@ impl Compact for TxType { EIP4844_TX_TYPE_ID => TxType::Eip4844, #[cfg(feature = "optimism")] DEPOSIT_TX_TYPE_ID => TxType::Deposit, - _ => panic!("Unsupported TxType identifier: {}", extended_identifier), + _ => panic!("Unsupported TxType identifier: {extended_identifier}"), } } - _ => panic!("Unknown identifier for TxType: {}", identifier), + _ => panic!("Unknown identifier for TxType: {identifier}"), }, buf, ) @@ -172,10 +172,9 @@ mod tests { let identifier = tx_type.to_compact(&mut buf); assert_eq!( identifier, expected_identifier, - "Unexpected identifier for TxType {:?}", - tx_type + "Unexpected identifier for TxType {tx_type:?}", ); - assert_eq!(buf, expected_buf, "Unexpected buffer for TxType {:?}", tx_type); + assert_eq!(buf, expected_buf, "Unexpected buffer for TxType {tx_type:?}"); } } @@ -192,15 +191,10 @@ mod tests { for (expected_type, identifier, buf) in cases { let (actual_type, remaining_buf) = TxType::from_compact(&buf, identifier); - assert_eq!( - actual_type, expected_type, - "Unexpected TxType for identifier {}", - identifier - ); + assert_eq!(actual_type, expected_type, "Unexpected TxType for identifier {identifier}",); assert!( remaining_buf.is_empty(), - "Buffer not fully consumed for identifier {}", - identifier + "Buffer not fully consumed for identifier {identifier}", ); } } diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 0cbc9b613..9d04fc033 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -49,7 +49,7 @@ where Ok(_) => {} // If the request is successful, do nothing Err(e) => { // If an error occurs, panic with the error message - panic!("Expected successful response, got error: {:?}", e); + panic!("Expected successful response, got error: {e:?}"); } } } @@ -61,7 +61,7 @@ where // Make the RPC request if let Ok(resp) = client.request::(method_name, params).await { // Panic if an unexpected successful response is received - panic!("Expected error response, got successful response: {:?}", resp); + panic!("Expected error response, got successful response: {resp:?}"); }; } diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index 721ad264d..8ec26deae 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -419,7 +419,7 @@ mod tests { let mut stream = client.debug_trace_transactions_in_block(block, opts).await.unwrap(); while let Some(res) = stream.next().await { if let Err((err, tx)) = res { - println!("failed to trace {:?} {}", tx, err); + println!("failed to trace {tx:?} {err}"); } } } diff --git a/crates/rpc/rpc-testing-util/src/trace.rs b/crates/rpc/rpc-testing-util/src/trace.rs index 2d3cff72a..5ab544c84 100644 --- a/crates/rpc/rpc-testing-util/src/trace.rs +++ b/crates/rpc/rpc-testing-util/src/trace.rs @@ -465,10 +465,9 @@ where } (Err((ref err1, ref block1)), Err((ref err2, ref block2))) => { assert_eq!( - format!("{:?}", err1), - format!("{:?}", err2), - "Different errors for block: {:?}", - block1 + format!("{err1:?}"), + format!("{err2:?}"), + "Different errors for block: {block1:?}" ); assert_eq!(block1, block2, "Mismatch in block ids."); } @@ -495,17 +494,15 @@ where similar_asserts::assert_eq!( trace1_data, trace2_data, - "Mismatch in trace results for transaction: {:?}", - tx_hash1 + "Mismatch in trace results for transaction: {tx_hash1:?}", ); assert_eq!(tx_hash1, tx_hash2, "Mismatch in transaction hashes."); } (Err((ref err1, ref tx_hash1)), Err((ref err2, ref tx_hash2))) => { assert_eq!( - format!("{:?}", err1), - format!("{:?}", err2), - "Different errors for transaction: {:?}", - tx_hash1 + format!("{err1:?}"), + format!("{err2:?}"), + "Different errors for transaction: {tx_hash1:?}", ); assert_eq!(tx_hash1, tx_hash2, "Mismatch in transaction hashes."); } @@ -554,20 +551,20 @@ mod tests { while let Some(result) = stream.next().await { match result { Ok((trace_result, tx_hash)) => { - println!("Success for tx_hash {:?}: {:?}", tx_hash, trace_result); + println!("Success for tx_hash {tx_hash:?}: {trace_result:?}"); successes += 1; all_results.push(Ok((trace_result, tx_hash))); } Err((error, tx_hash)) => { - println!("Error for tx_hash {:?}: {:?}", tx_hash, error); + println!("Error for tx_hash {tx_hash:?}: {error:?}"); failures += 1; all_results.push(Err((error, tx_hash))); } } } - println!("Total successes: {}", successes); - println!("Total failures: {}", failures); + println!("Total successes: {successes}"); + println!("Total failures: {failures}"); } #[tokio::test] @@ -587,10 +584,10 @@ mod tests { while let Some(result) = stream.next().await { match result { Ok(trace_result) => { - println!("Success: {:?}", trace_result); + println!("Success: {trace_result:?}"); } Err(error) => { - println!("Error: {:?}", error); + println!("Error: {error:?}"); } } } @@ -609,10 +606,10 @@ mod tests { while let Some(result) = stream.next().await { match result { Ok(trace) => { - println!("Received trace: {:?}", trace); + println!("Received trace: {trace:?}"); } Err(e) => { - println!("Error fetching trace: {:?}", e); + println!("Error fetching trace: {e:?}"); } } } @@ -639,10 +636,10 @@ mod tests { while let Some(result) = stream.next().await { match result { Ok(trace) => { - println!("Received trace: {:?}", trace); + println!("Received trace: {trace:?}"); } Err(e) => { - println!("Error fetching trace: {:?}", e); + println!("Error fetching trace: {e:?}"); } } } @@ -665,19 +662,19 @@ mod tests { while let Some(result) = stream.next().await { match result { Ok(trace_result) => { - println!("Success: {:?}", trace_result); + println!("Success: {trace_result:?}"); successes += 1; all_results.push(Ok(trace_result)); } Err((error, request)) => { - println!("Error for request {:?}: {:?}", request, error); + println!("Error for request {request:?}: {error:?}"); failures += 1; all_results.push(Err((error, request))); } } } - println!("Total successes: {}", successes); - println!("Total failures: {}", failures); + println!("Total successes: {successes}"); + println!("Total failures: {failures}"); } } diff --git a/crates/rpc/rpc-testing-util/src/utils.rs b/crates/rpc/rpc-testing-util/src/utils.rs index 8a74f90c9..e4b4acb4e 100644 --- a/crates/rpc/rpc-testing-util/src/utils.rs +++ b/crates/rpc/rpc-testing-util/src/utils.rs @@ -8,6 +8,6 @@ pub fn parse_env_url(var: &str) -> Result { if var.starts_with("http") { Ok(var) } else { - Ok(format!("http://{}", var)) + Ok(format!("http://{var}")) } } diff --git a/crates/rpc/rpc-testing-util/tests/it/trace.rs b/crates/rpc/rpc-testing-util/tests/it/trace.rs index 2f1b53a20..a6439f074 100644 --- a/crates/rpc/rpc-testing-util/tests/it/trace.rs +++ b/crates/rpc/rpc-testing-util/tests/it/trace.rs @@ -44,7 +44,7 @@ async fn replay_transactions() { let mut stream = client.replay_transactions(tx_hashes, trace_types); let now = Instant::now(); while let Some(replay_txs) = stream.next().await { - println!("Transaction: {:?}", replay_txs); + println!("Transaction: {replay_txs:?}"); println!("Replayed transactions in {:?}", now.elapsed()); } } @@ -65,7 +65,7 @@ async fn trace_filters() { let mut stream = client.trace_filter_stream(filters); let start_time = Instant::now(); while let Some(trace) = stream.next().await { - println!("Transaction Trace: {:?}", trace); + println!("Transaction Trace: {trace:?}"); println!("Duration since test start: {:?}", start_time.elapsed()); } } @@ -82,10 +82,10 @@ async fn trace_call() { while let Some(result) = stream.next().await { match result { Ok(trace_result) => { - println!("Trace Result: {:?}", trace_result); + println!("Trace Result: {trace_result:?}"); } Err((error, request)) => { - eprintln!("Error for request {:?}: {:?}", request, error); + eprintln!("Error for request {request:?}: {error:?}"); } } } diff --git a/crates/storage/db/src/lib.rs b/crates/storage/db/src/lib.rs index 813f11757..938a94d46 100644 --- a/crates/storage/db/src/lib.rs +++ b/crates/storage/db/src/lib.rs @@ -249,7 +249,7 @@ pub mod test_utils { /// Create read/write database for testing pub fn create_test_rw_db() -> Arc> { let path = tempdir_path(); - let emsg = format!("{}: {:?}", ERROR_DB_CREATION, path); + let emsg = format!("{ERROR_DB_CREATION}: {path:?}"); let db = init_db( &path, diff --git a/crates/storage/db/src/tables/mod.rs b/crates/storage/db/src/tables/mod.rs index dca1a05a3..676ed5ebc 100644 --- a/crates/storage/db/src/tables/mod.rs +++ b/crates/storage/db/src/tables/mod.rs @@ -394,7 +394,7 @@ mod tests { #[test] fn parse_table_from_str() { for table in Tables::ALL { - assert_eq!(format!("{:?}", table), table.name()); + assert_eq!(format!("{table:?}"), table.name()); assert_eq!(table.to_string(), table.name()); assert_eq!(Tables::from_str(table.name()).unwrap(), *table); } diff --git a/crates/storage/provider/src/chain.rs b/crates/storage/provider/src/chain.rs index 5f703426d..b2f2ab410 100644 --- a/crates/storage/provider/src/chain.rs +++ b/crates/storage/provider/src/chain.rs @@ -324,9 +324,9 @@ impl<'a> fmt::Display for DisplayBlocksChain<'a> { write!(f, "[")?; let mut iter = self.0.values().map(|block| block.num_hash()); if let Some(block_num_hash) = iter.next() { - write!(f, "{:?}", block_num_hash)?; + write!(f, "{block_num_hash:?}")?; for block_num_hash_iter in iter { - write!(f, ", {:?}", block_num_hash_iter)?; + write!(f, ", {block_num_hash_iter:?}")?; } } write!(f, "]")?; diff --git a/crates/transaction-pool/benches/priority.rs b/crates/transaction-pool/benches/priority.rs index 0c8847fb7..8a63da3d4 100644 --- a/crates/transaction-pool/benches/priority.rs +++ b/crates/transaction-pool/benches/priority.rs @@ -22,7 +22,7 @@ fn priority_bench( description: &str, input_data: (u128, u128, u128, u128), ) { - let group_id = format!("txpool | {}", description); + let group_id = format!("txpool | {description}"); group.bench_function(group_id, |b| { b.iter(|| { @@ -41,7 +41,7 @@ fn fee_jump_bench( description: &str, input_data: (u128, u128), ) { - let group_id = format!("txpool | {}", description); + let group_id = format!("txpool | {description}"); group.bench_function(group_id, |b| { b.iter(|| { diff --git a/crates/transaction-pool/src/blobstore/disk.rs b/crates/transaction-pool/src/blobstore/disk.rs index d1d9e5490..9d1a3b3fc 100644 --- a/crates/transaction-pool/src/blobstore/disk.rs +++ b/crates/transaction-pool/src/blobstore/disk.rs @@ -458,7 +458,7 @@ mod tests { } let all = store.get_all(all_hashes.clone()).unwrap(); for (tx, blob) in all { - assert!(blobs.contains(&(tx, blob)), "missing blob {:?}", tx); + assert!(blobs.contains(&(tx, blob)), "missing blob {tx:?}"); } assert!(store.contains(all_hashes[0]).unwrap()); diff --git a/crates/transaction-pool/src/pool/blob.rs b/crates/transaction-pool/src/pool/blob.rs index b0583c502..b49b0db98 100644 --- a/crates/transaction-pool/src/pool/blob.rs +++ b/crates/transaction-pool/src/pool/blob.rs @@ -690,8 +690,7 @@ mod tests { let actual = fee_delta(tx_fee, base_fee); assert_eq!( actual, expected, - "fee_delta({}, {}) = {}, expected: {}", - tx_fee, base_fee, actual, expected + "fee_delta({tx_fee}, {base_fee}) = {actual}, expected: {expected}" ); } } diff --git a/crates/transaction-pool/src/pool/parked.rs b/crates/transaction-pool/src/pool/parked.rs index 78def4e65..2815deaee 100644 --- a/crates/transaction-pool/src/pool/parked.rs +++ b/crates/transaction-pool/src/pool/parked.rs @@ -124,8 +124,7 @@ impl ParkedPool { assert!( self.last_sender_submission .remove(&SubmissionSenderId::new(sender_id, removed_sender.last_submission_id)), - "last sender transaction not found {:?}", - sender_id + "last sender transaction not found {sender_id:?}" ); } diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index d31ae8d77..c9750e4e6 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -2445,7 +2445,7 @@ mod tests { MockTransaction::eip4844().set_sender(tx.get_sender()).inc_price_by(100).inc_limit(); let blob = f.validated(tx); let err = pool.insert_tx(blob, on_chain_balance, on_chain_nonce).unwrap_err(); - assert!(matches!(err, InsertErr::TxTypeConflict { .. }), "{:?}", err); + assert!(matches!(err, InsertErr::TxTypeConflict { .. }), "{err:?}"); } #[test] @@ -2461,7 +2461,7 @@ mod tests { MockTransaction::eip1559().set_sender(tx.get_sender()).inc_price_by(100).inc_limit(); let tx = f.validated(tx); let err = pool.insert_tx(tx, on_chain_balance, on_chain_nonce).unwrap_err(); - assert!(matches!(err, InsertErr::TxTypeConflict { .. }), "{:?}", err); + assert!(matches!(err, InsertErr::TxTypeConflict { .. }), "{err:?}"); } // insert nonce then nonce - 1 diff --git a/testing/ef-tests/src/models.rs b/testing/ef-tests/src/models.rs index 2dddc540c..a30aa3d93 100644 --- a/testing/ef-tests/src/models.rs +++ b/testing/ef-tests/src/models.rs @@ -235,18 +235,16 @@ impl Account { assert_equal( *value, entry.value, - &format!("Storage for slot {:?} does not match", slot), + &format!("Storage for slot {slot:?} does not match"), )?; } else { return Err(Error::Assertion(format!( - "Slot {:?} is missing from the database. Expected {:?}", - slot, value + "Slot {slot:?} is missing from the database. Expected {value:?}" ))) } } else { return Err(Error::Assertion(format!( - "Slot {:?} is missing from the database. Expected {:?}", - slot, value + "Slot {slot:?} is missing from the database. Expected {value:?}" ))) } } diff --git a/testing/ef-tests/src/suite.rs b/testing/ef-tests/src/suite.rs index 25b4ad14b..b26e12994 100644 --- a/testing/ef-tests/src/suite.rs +++ b/testing/ef-tests/src/suite.rs @@ -33,7 +33,7 @@ pub trait Suite { .join(self.suite_name()); // Verify that the path exists - assert!(suite_path.exists(), "Test suite path does not exist: {:?}", suite_path); + assert!(suite_path.exists(), "Test suite path does not exist: {suite_path:?}"); // Find all files with the ".json" extension in the test suite directory let test_cases = find_all_files_with_extension(&suite_path, ".json")