Skip to content

Commit

Permalink
Enable clippy's uninlined_format_args linter (paradigmxyz#7204)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
jtraglia and mattsse authored Mar 18, 2024
1 parent 5b94dbb commit b7ef60b
Show file tree
Hide file tree
Showing 31 changed files with 84 additions and 104 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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:?}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/commands/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Command {
match content {
Some(content) => {
if raw {
println!("{:?}", content);
println!("{content:?}");
} else {
match segment {
StaticFileSegment::Headers => {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl<DB: Database> TableViewer<()> for GetValueViewer<'_, DB> {

match content {
Some(content) => {
println!("{}", content);
println!("{content}");
}
None => {
error!(target: "reth::cli", "No content for the given table key.");
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl ImportCommand {
/// Loads the reth config
fn load_config(&self, config_path: PathBuf) -> eyre::Result<Config> {
confy::load_path::<Config>(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:?}"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire/src/ethstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ mod tests {
assert_eq!(transactions.len(), 1);
}
Err(e) => {
panic!("error: {:?}", e);
panic!("error: {e:?}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/big_pooled_txs_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
}
}
}
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion crates/node-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<DB, State> NodeBuilder<DB, State> {
let config_path = self.config.config.clone().unwrap_or_else(|| data_dir.config_path());

let mut config = confy::load_path::<reth_config::Config>(&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");

Expand Down
12 changes: 6 additions & 6 deletions crates/node-core/src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,28 +357,28 @@ mod tests {
fn test_maybe_data_dir_path() {
let path = MaybePlatformPath::<DataDirPath>::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::<DataDirPath>::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::<DataDirPath>::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::<DataDirPath>::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::<DataDirPath>::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:?}");
}
}
2 changes: 1 addition & 1 deletion crates/primitives/benches/integer_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mod elias_fano {
impl fmt::Debug for IntegerList {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let vec: Vec<usize> = self.0.iter(0).collect();
write!(f, "IntegerList {:?}", vec)
write!(f, "IntegerList {vec:?}")
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/benches/validate_blob_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
}
});
});
Expand Down
30 changes: 11 additions & 19 deletions crates/primitives/src/chain/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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)?;
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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:#?} ",
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/compression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/integer_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> = self.0.iter().collect();
write!(f, "IntegerList {:?}", vec)
write!(f, "IntegerList {vec:?}")
}
}

Expand Down
18 changes: 6 additions & 12 deletions crates/primitives/src/transaction/tx_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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:?}");
}
}

Expand All @@ -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}",
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-builder/tests/it/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
}
}
}
Expand All @@ -61,7 +61,7 @@ where
// Make the RPC request
if let Ok(resp) = client.request::<R, _>(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:?}");
};
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-testing-util/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
}
Expand Down
Loading

0 comments on commit b7ef60b

Please sign in to comment.