Enable clippy's uninlined_format_args linter (#7204)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Justin Traglia
2024-03-18 18:29:19 -05:00
committed by GitHub
parent 5b94dbb697
commit b7ef60b899
31 changed files with 84 additions and 104 deletions

View File

@@ -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:#?} ",
);
}

View File

@@ -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);
}

View File

@@ -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:?}")
}
}

View File

@@ -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}",
);
}
}