Skip to content

Commit 4ad7e15

Browse files
Address Clippy 1.73 lints on Deneb branch (sigp#4810)
* Address Clippy 1.73 lints (sigp#4809) ## Proposed Changes Fix Clippy lints enabled by default in Rust 1.73.0, released today. * Address Clippy 1.73 lints. --------- Co-authored-by: Michael Sproul <[email protected]>
1 parent 203ac65 commit 4ad7e15

File tree

12 files changed

+28
-35
lines changed

12 files changed

+28
-35
lines changed

beacon_node/beacon_chain/src/blob_verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ pub struct KzgVerifiedBlob<T: EthSpec> {
451451

452452
impl<T: EthSpec> PartialOrd for KzgVerifiedBlob<T> {
453453
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
454-
self.blob.partial_cmp(&other.blob)
454+
Some(self.cmp(other))
455455
}
456456
}
457457

beacon_node/beacon_chain/src/eth1_finalization_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl CheckpointMap {
6767
pub fn insert(&mut self, checkpoint: Checkpoint, eth1_finalization_data: Eth1FinalizationData) {
6868
self.store
6969
.entry(checkpoint.epoch)
70-
.or_insert_with(Vec::new)
70+
.or_default()
7171
.push((checkpoint.root, eth1_finalization_data));
7272

7373
// faster to reduce size after the fact than do pre-checking to see

beacon_node/beacon_chain/src/historical_blocks.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
172172
let signature_set = signed_blocks
173173
.iter()
174174
.zip_eq(block_roots)
175-
.filter_map(|(block, block_root)| {
176-
(block_root != self.genesis_block_root).then(|| {
177-
block_proposal_signature_set_from_parts(
178-
block,
179-
Some(block_root),
180-
block.message().proposer_index(),
181-
&self.spec.fork_at_epoch(block.message().epoch()),
182-
self.genesis_validators_root,
183-
|validator_index| {
184-
pubkey_cache.get(validator_index).cloned().map(Cow::Owned)
185-
},
186-
&self.spec,
187-
)
188-
})
175+
.filter(|&(_block, block_root)| (block_root != self.genesis_block_root))
176+
.map(|(block, block_root)| {
177+
block_proposal_signature_set_from_parts(
178+
block,
179+
Some(block_root),
180+
block.message().proposer_index(),
181+
&self.spec.fork_at_epoch(block.message().epoch()),
182+
self.genesis_validators_root,
183+
|validator_index| pubkey_cache.get(validator_index).cloned().map(Cow::Owned),
184+
&self.spec,
185+
)
189186
})
190187
.collect::<Result<Vec<_>, _>>()
191188
.map_err(HistoricalBlockError::SignatureSet)

beacon_node/execution_layer/src/test_utils/execution_block_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
371371
let block_hash = block.block_hash();
372372
self.block_hashes
373373
.entry(block.block_number())
374-
.or_insert_with(Vec::new)
374+
.or_default()
375375
.push(block_hash);
376376
self.blocks.insert(block_hash, block);
377377

beacon_node/http_api/src/standard_block_rewards.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use beacon_chain::{BeaconChain, BeaconChainTypes};
55
use eth2::lighthouse::StandardBlockReward;
66
use std::sync::Arc;
77
use warp_utils::reject::beacon_chain_error;
8-
//// The difference between block_rewards and beacon_block_rewards is the later returns block
9-
//// reward format that satisfies beacon-api specs
8+
/// The difference between block_rewards and beacon_block_rewards is the later returns block
9+
/// reward format that satisfies beacon-api specs
1010
pub fn compute_beacon_block_rewards<T: BeaconChainTypes>(
1111
chain: Arc<BeaconChain<T>>,
1212
block_id: BlockId,

beacon_node/lighthouse_network/src/peer_manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
10551055
Subnet::Attestation(_) => {
10561056
subnet_to_peer
10571057
.entry(subnet)
1058-
.or_insert_with(Vec::new)
1058+
.or_default()
10591059
.push((*peer_id, info.clone()));
10601060
}
10611061
Subnet::SyncCommittee(id) => {

beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,15 @@ impl Eq for Score {}
330330

331331
impl PartialOrd for Score {
332332
fn partial_cmp(&self, other: &Score) -> Option<std::cmp::Ordering> {
333-
self.score().partial_cmp(&other.score())
333+
Some(self.cmp(other))
334334
}
335335
}
336336

337337
impl Ord for Score {
338338
fn cmp(&self, other: &Score) -> std::cmp::Ordering {
339-
self.partial_cmp(other).unwrap_or(std::cmp::Ordering::Equal)
339+
self.score()
340+
.partial_cmp(&other.score())
341+
.unwrap_or(std::cmp::Ordering::Equal)
340342
}
341343
}
342344

beacon_node/operation_pool/src/attestation_storage.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,8 @@ impl<T: EthSpec> AttestationMap<T> {
151151
indexed,
152152
} = SplitAttestation::new(attestation, attesting_indices);
153153

154-
let attestation_map = self
155-
.checkpoint_map
156-
.entry(checkpoint)
157-
.or_insert_with(AttestationDataMap::default);
158-
let attestations = attestation_map
159-
.attestations
160-
.entry(data)
161-
.or_insert_with(Vec::new);
154+
let attestation_map = self.checkpoint_map.entry(checkpoint).or_default();
155+
let attestations = attestation_map.attestations.entry(data).or_default();
162156

163157
// Greedily aggregate the attestation with all existing attestations.
164158
// NOTE: this is sub-optimal and in future we will remove this in favour of max-clique

beacon_node/store/src/memory_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<E: EthSpec> KeyValueStore<E> for MemoryStore<E> {
4848
self.col_keys
4949
.write()
5050
.entry(col.as_bytes().to_vec())
51-
.or_insert_with(HashSet::new)
51+
.or_default()
5252
.insert(key.to_vec());
5353
Ok(())
5454
}

consensus/types/src/blob_sidecar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl BlobIdentifier {
3838

3939
impl PartialOrd for BlobIdentifier {
4040
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
41-
self.index.partial_cmp(&other.index)
41+
Some(self.cmp(other))
4242
}
4343
}
4444

@@ -109,7 +109,7 @@ impl<E: EthSpec> From<BlobSidecar<E>> for BlindedBlobSidecar {
109109

110110
impl<T: EthSpec> PartialOrd for BlobSidecar<T> {
111111
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
112-
self.index.partial_cmp(&other.index)
112+
Some(self.cmp(other))
113113
}
114114
}
115115

0 commit comments

Comments
 (0)