Skip to content

Commit 1f6850f

Browse files
authored
Rust 1.84 lints (#6781)
* Fix few lints * Fix remaining lints * Use fully qualified syntax
1 parent 87b72de commit 1f6850f

File tree

61 files changed

+110
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+110
-138
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
573573
.start_slot(T::EthSpec::slots_per_epoch());
574574
let is_canonical = self
575575
.block_root_at_slot(block_slot, WhenSlotSkipped::None)?
576-
.map_or(false, |canonical_root| block_root == &canonical_root);
576+
.is_some_and(|canonical_root| block_root == &canonical_root);
577577
Ok(block_slot <= finalized_slot && is_canonical)
578578
}
579579

@@ -604,7 +604,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
604604
let slot_is_finalized = state_slot <= finalized_slot;
605605
let canonical = self
606606
.state_root_at_slot(state_slot)?
607-
.map_or(false, |canonical_root| state_root == &canonical_root);
607+
.is_some_and(|canonical_root| state_root == &canonical_root);
608608
Ok(FinalizationAndCanonicity {
609609
slot_is_finalized,
610610
canonical,
@@ -5118,9 +5118,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51185118
.start_of(slot)
51195119
.unwrap_or_else(|| Duration::from_secs(0)),
51205120
);
5121-
block_delays.observed.map_or(false, |delay| {
5122-
delay >= self.slot_clock.unagg_attestation_production_delay()
5123-
})
5121+
block_delays
5122+
.observed
5123+
.is_some_and(|delay| delay >= self.slot_clock.unagg_attestation_production_delay())
51245124
}
51255125

51265126
/// Produce a block for some `slot` upon the given `state`.

beacon_node/beacon_chain/src/canonical_head.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,11 +1254,7 @@ pub fn find_reorg_slot<E: EthSpec>(
12541254
($state: ident, $block_root: ident) => {
12551255
std::iter::once(Ok(($state.slot(), $block_root)))
12561256
.chain($state.rev_iter_block_roots(spec))
1257-
.skip_while(|result| {
1258-
result
1259-
.as_ref()
1260-
.map_or(false, |(slot, _)| *slot > lowest_slot)
1261-
})
1257+
.skip_while(|result| result.as_ref().is_ok_and(|(slot, _)| *slot > lowest_slot))
12621258
};
12631259
}
12641260

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,13 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
519519
/// Returns true if the given epoch lies within the da boundary and false otherwise.
520520
pub fn da_check_required_for_epoch(&self, block_epoch: Epoch) -> bool {
521521
self.data_availability_boundary()
522-
.map_or(false, |da_epoch| block_epoch >= da_epoch)
522+
.is_some_and(|da_epoch| block_epoch >= da_epoch)
523523
}
524524

525525
/// Returns `true` if the current epoch is greater than or equal to the `Deneb` epoch.
526526
pub fn is_deneb(&self) -> bool {
527-
self.slot_clock.now().map_or(false, |slot| {
528-
self.spec.deneb_fork_epoch.map_or(false, |deneb_epoch| {
527+
self.slot_clock.now().is_some_and(|slot| {
528+
self.spec.deneb_fork_epoch.is_some_and(|deneb_epoch| {
529529
let now_epoch = slot.epoch(T::EthSpec::slots_per_epoch());
530530
now_epoch >= deneb_epoch
531531
})

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,10 @@ impl<E: EthSpec> PendingComponents<E> {
228228
);
229229

230230
let all_blobs_received = block_kzg_commitments_count_opt
231-
.map_or(false, |num_expected_blobs| {
232-
num_expected_blobs == num_received_blobs
233-
});
231+
.is_some_and(|num_expected_blobs| num_expected_blobs == num_received_blobs);
234232

235-
let all_columns_received = expected_columns_opt.map_or(false, |num_expected_columns| {
236-
num_expected_columns == num_received_columns
237-
});
233+
let all_columns_received = expected_columns_opt
234+
.is_some_and(|num_expected_columns| num_expected_columns == num_received_columns);
238235

239236
all_blobs_received || all_columns_received
240237
}

beacon_node/beacon_chain/src/early_attester_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
145145
self.item
146146
.read()
147147
.as_ref()
148-
.map_or(false, |item| item.beacon_block_root == block_root)
148+
.is_some_and(|item| item.beacon_block_root == block_root)
149149
}
150150

151151
/// Returns the block, if `block_root` matches the cached item.

beacon_node/beacon_chain/src/eth1_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn get_sync_status<E: EthSpec>(
153153
// Lighthouse is "cached and ready" when it has cached enough blocks to cover the start of the
154154
// current voting period.
155155
let lighthouse_is_cached_and_ready =
156-
latest_cached_block_timestamp.map_or(false, |t| t >= voting_target_timestamp);
156+
latest_cached_block_timestamp.is_some_and(|t| t >= voting_target_timestamp);
157157

158158
Some(Eth1SyncStatusData {
159159
head_block_number,

beacon_node/beacon_chain/src/execution_payload.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
127127
/// contains a few extra checks by running `partially_verify_execution_payload` first:
128128
///
129129
/// https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/bellatrix/beacon-chain.md#notify_new_payload
130-
async fn notify_new_payload<'a, T: BeaconChainTypes>(
130+
async fn notify_new_payload<T: BeaconChainTypes>(
131131
chain: &Arc<BeaconChain<T>>,
132-
block: BeaconBlockRef<'a, T::EthSpec>,
132+
block: BeaconBlockRef<'_, T::EthSpec>,
133133
) -> Result<PayloadVerificationStatus, BlockError> {
134134
let execution_layer = chain
135135
.execution_layer
@@ -230,9 +230,9 @@ async fn notify_new_payload<'a, T: BeaconChainTypes>(
230230
/// Equivalent to the `validate_merge_block` function in the merge Fork Choice Changes:
231231
///
232232
/// https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/fork-choice.md#validate_merge_block
233-
pub async fn validate_merge_block<'a, T: BeaconChainTypes>(
233+
pub async fn validate_merge_block<T: BeaconChainTypes>(
234234
chain: &Arc<BeaconChain<T>>,
235-
block: BeaconBlockRef<'a, T::EthSpec>,
235+
block: BeaconBlockRef<'_, T::EthSpec>,
236236
allow_optimistic_import: AllowOptimisticImport,
237237
) -> Result<(), BlockError> {
238238
let spec = &chain.spec;

beacon_node/beacon_chain/src/graffiti_calculator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,7 @@ mod tests {
293293
.await
294294
.unwrap();
295295

296-
let version_bytes = std::cmp::min(
297-
lighthouse_version::VERSION.as_bytes().len(),
298-
GRAFFITI_BYTES_LEN,
299-
);
296+
let version_bytes = std::cmp::min(lighthouse_version::VERSION.len(), GRAFFITI_BYTES_LEN);
300297
// grab the slice of the graffiti that corresponds to the lighthouse version
301298
let graffiti_slice =
302299
&harness.chain.graffiti_calculator.get_graffiti(None).await.0[..version_bytes];
@@ -361,7 +358,7 @@ mod tests {
361358

362359
let graffiti_str = "nice graffiti bro";
363360
let mut graffiti_bytes = [0u8; GRAFFITI_BYTES_LEN];
364-
graffiti_bytes[..graffiti_str.as_bytes().len()].copy_from_slice(graffiti_str.as_bytes());
361+
graffiti_bytes[..graffiti_str.len()].copy_from_slice(graffiti_str.as_bytes());
365362

366363
let found_graffiti = harness
367364
.chain

beacon_node/beacon_chain/src/observed_aggregates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<I> SlotHashSet<I> {
293293
Ok(self
294294
.map
295295
.get(&root)
296-
.map_or(false, |agg| agg.iter().any(|val| item.is_subset(val))))
296+
.is_some_and(|agg| agg.iter().any(|val| item.is_subset(val))))
297297
}
298298

299299
/// The number of observed items in `self`.

beacon_node/beacon_chain/src/observed_attesters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl Item<()> for EpochBitfield {
130130
fn get(&self, validator_index: usize) -> Option<()> {
131131
self.bitfield
132132
.get(validator_index)
133-
.map_or(false, |bit| *bit)
133+
.is_some_and(|bit| *bit)
134134
.then_some(())
135135
}
136136
}
@@ -336,7 +336,7 @@ impl<T: Item<()>, E: EthSpec> AutoPruningEpochContainer<T, E> {
336336
let exists = self
337337
.items
338338
.get(&epoch)
339-
.map_or(false, |item| item.get(validator_index).is_some());
339+
.is_some_and(|item| item.get(validator_index).is_some());
340340

341341
Ok(exists)
342342
}

0 commit comments

Comments
 (0)