diff --git a/bench-exchange/src/bench.rs b/bench-exchange/src/bench.rs index cdff1fb304..933cf905fa 100644 --- a/bench-exchange/src/bench.rs +++ b/bench-exchange/src/bench.rs @@ -179,19 +179,13 @@ where info!("Generating {:?} account keys", total_keys); let mut account_keypairs = generate_keypairs(total_keys); - let src_keypairs: Vec<_> = account_keypairs - .drain(0..accounts_in_groups) - .map(|keypair| keypair) - .collect(); + let src_keypairs: Vec<_> = account_keypairs.drain(0..accounts_in_groups).collect(); let src_pubkeys: Vec = src_keypairs .iter() .map(|keypair| keypair.pubkey()) .collect(); - let profit_keypairs: Vec<_> = account_keypairs - .drain(0..accounts_in_groups) - .map(|keypair| keypair) - .collect(); + let profit_keypairs: Vec<_> = account_keypairs.drain(0..accounts_in_groups).collect(); let profit_pubkeys: Vec = profit_keypairs .iter() .map(|keypair| keypair.pubkey()) diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 5d7a86ed8a..93229fea3e 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -780,7 +780,7 @@ impl ClusterInfo { .crds .table .values() - .filter_map(|x| x.value.snapshot_hash().map(|v| v)) + .filter_map(|x| x.value.snapshot_hash()) .filter_map(|x| { for (table_slot, hash) in &x.hashes { if *table_slot == slot { diff --git a/core/src/gossip_service.rs b/core/src/gossip_service.rs index d2f0d184ba..0494b168dd 100644 --- a/core/src/gossip_service.rs +++ b/core/src/gossip_service.rs @@ -160,7 +160,6 @@ pub fn get_multi_client(nodes: &[ContactInfo]) -> (ThinClient, usize) { let addrs: Vec<_> = nodes .iter() .filter_map(ContactInfo::valid_client_facing_addr) - .map(|addrs| addrs) .collect(); let rpc_addrs: Vec<_> = addrs.iter().map(|addr| addr.0).collect(); let tpu_addrs: Vec<_> = addrs.iter().map(|addr| addr.1).collect(); diff --git a/core/tests/cluster_info.rs b/core/tests/cluster_info.rs index 55bb6b132c..5e82b5a0c7 100644 --- a/core/tests/cluster_info.rs +++ b/core/tests/cluster_info.rs @@ -202,7 +202,7 @@ fn run_simulation(stakes: &[u64], fanout: usize) { #[test] #[serial] fn test_retransmit_small() { - let stakes: Vec<_> = (0..200).map(|i| i).collect(); + let stakes: Vec<_> = (0..200).collect(); run_simulation(&stakes, 200); } @@ -211,7 +211,7 @@ fn test_retransmit_small() { #[serial] fn test_retransmit_medium() { let num_nodes = 2000; - let stakes: Vec<_> = (0..num_nodes).map(|i| i).collect(); + let stakes: Vec<_> = (0..num_nodes).collect(); run_simulation(&stakes, 200); } @@ -229,6 +229,6 @@ fn test_retransmit_medium_equal_stakes() { #[serial] fn test_retransmit_large() { let num_nodes = 4000; - let stakes: Vec<_> = (0..num_nodes).map(|i| i).collect(); + let stakes: Vec<_> = (0..num_nodes).collect(); run_simulation(&stakes, 2); } diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 892a425a6d..c057cb2787 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -2170,11 +2170,7 @@ impl Blockstore { } pub fn is_root(&self, slot: Slot) -> bool { - if let Ok(Some(true)) = self.db.get::(slot) { - true - } else { - false - } + matches!(self.db.get::(slot), Ok(Some(true))) } pub fn set_roots(&self, rooted_slots: &[u64]) -> Result<()> { @@ -2194,15 +2190,12 @@ impl Blockstore { } pub fn is_dead(&self, slot: Slot) -> bool { - if let Some(true) = self - .db - .get::(slot) - .expect("fetch from DeadSlots column family failed") - { - true - } else { - false - } + matches!( + self.db + .get::(slot) + .expect("fetch from DeadSlots column family failed"), + Some(true) + ) } pub fn set_dead_slot(&self, slot: Slot) -> Result<()> { diff --git a/merkle-tree/src/merkle_tree.rs b/merkle-tree/src/merkle_tree.rs index 4b39d3f5df..7bec5ed043 100644 --- a/merkle-tree/src/merkle_tree.rs +++ b/merkle-tree/src/merkle_tree.rs @@ -58,10 +58,7 @@ impl<'a> Proof<'a> { None } }); - match result { - Some(_) => true, - _ => false, - } + matches!(result, Some(_)) } } diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 0c008bebb3..488ac4face 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1519,13 +1519,9 @@ impl AccountsDB { hashes = new_hashes.chunks(fanout).map(|x| x.to_vec()).collect(); } let mut hasher = Hasher::default(); - hashes - .into_iter() - .flatten() - .map(|hash| hash) - .for_each(|hash| { - hasher.hash(hash.as_ref()); - }); + hashes.into_iter().flatten().for_each(|hash| { + hasher.hash(hash.as_ref()); + }); hasher.result() } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index bc01d4f739..130266a44a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -198,10 +198,7 @@ pub enum HashAgeKind { impl HashAgeKind { pub fn is_durable_nonce(&self) -> bool { - match self { - HashAgeKind::DurableNonce(_, _) => true, - _ => false, - } + matches!(self, HashAgeKind::DurableNonce(_, _)) } } diff --git a/runtime/src/nonce_utils.rs b/runtime/src/nonce_utils.rs index d257e9a86a..9fe3fd9d29 100644 --- a/runtime/src/nonce_utils.rs +++ b/runtime/src/nonce_utils.rs @@ -23,10 +23,8 @@ pub fn transaction_uses_durable_nonce(tx: &Transaction) -> Option<&CompiledInstr Some(program_id) => system_program::check_id(&program_id), _ => false, } - } && match limited_deserialize(&maybe_ix.data) { - Ok(SystemInstruction::AdvanceNonceAccount) => true, - _ => false, - }) + } && matches!(limited_deserialize(&maybe_ix.data), Ok(SystemInstruction::AdvanceNonceAccount)) + ) } pub fn get_nonce_pubkey_from_instruction<'a>(