Rust 1.85 lints (#7019)

N/A


  2 changes:
1. Replace Option::map_or(true, ...) with is_none_or(...)
2. Remove unnecessary `Into::into` blocks where the type conversion is apparent from the types
This commit is contained in:
Pawan Dhananjay
2025-02-23 18:36:13 -08:00
committed by GitHub
parent ff739d56be
commit b3b6aea1c5
33 changed files with 102 additions and 128 deletions

View File

@@ -1450,19 +1450,17 @@ where
return Err(Error::UnknownTargetRoot(target.root));
}
chain
.with_committee_cache(target.root, attestation_epoch, |committee_cache, _| {
let committees_per_slot = committee_cache.committees_per_slot();
chain.with_committee_cache(target.root, attestation_epoch, |committee_cache, _| {
let committees_per_slot = committee_cache.committees_per_slot();
Ok(committee_cache
.get_beacon_committees_at_slot(attestation.data().slot)
.map(|committees| map_fn((committees, committees_per_slot)))
.unwrap_or_else(|_| {
Err(Error::NoCommitteeForSlotAndIndex {
slot: attestation.data().slot,
index: attestation.committee_index().unwrap_or(0),
})
}))
})
.map_err(BeaconChainError::from)?
Ok(committee_cache
.get_beacon_committees_at_slot(attestation.data().slot)
.map(|committees| map_fn((committees, committees_per_slot)))
.unwrap_or_else(|_| {
Err(Error::NoCommitteeForSlotAndIndex {
slot: attestation.data().slot,
index: attestation.committee_index().unwrap_or(0),
})
}))
})?
}

View File

@@ -6506,9 +6506,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// Returns `true` if the given slot is prior to the `bellatrix_fork_epoch`.
pub fn slot_is_prior_to_bellatrix(&self, slot: Slot) -> bool {
self.spec.bellatrix_fork_epoch.map_or(true, |bellatrix| {
slot.epoch(T::EthSpec::slots_per_epoch()) < bellatrix
})
self.spec
.bellatrix_fork_epoch
.is_none_or(|bellatrix| slot.epoch(T::EthSpec::slots_per_epoch()) < bellatrix)
}
/// Returns the value of `execution_optimistic` for `block`.

View File

@@ -173,7 +173,7 @@ impl BlockTimesCache {
if block_times
.timestamps
.all_blobs_observed
.map_or(true, |prev| timestamp > prev)
.is_none_or(|prev| timestamp > prev)
{
block_times.timestamps.all_blobs_observed = Some(timestamp);
}
@@ -195,7 +195,7 @@ impl BlockTimesCache {
.entry(block_root)
.or_insert_with(|| BlockTimesCacheValue::new(slot));
let existing_timestamp = field(&mut block_times.timestamps);
if existing_timestamp.map_or(true, |prev| timestamp < prev) {
if existing_timestamp.is_none_or(|prev| timestamp < prev) {
*existing_timestamp = Some(timestamp);
}
}

View File

@@ -307,7 +307,6 @@ impl<E: EthSpec> PendingComponents<E> {
.map(|b| b.map(|b| b.to_blob()))
.take(num_blobs_expected)
.collect::<Option<Vec<_>>>()
.map(Into::into)
else {
return Err(AvailabilityCheckError::Unexpected);
};

View File

@@ -138,7 +138,7 @@ impl ShufflingCache {
.get(&key)
// Replace the committee if it's not present or if it's a promise. A bird in the hand is
// worth two in the promise-bush!
.map_or(true, CacheItem::is_promise)
.is_none_or(CacheItem::is_promise)
{
self.insert_cache_item(
key,

View File

@@ -628,7 +628,7 @@ impl<E: EthSpec> ValidatorMonitor<E> {
// the proposer shuffling cache lock when there are lots of missed blocks.
if proposers_per_epoch
.as_ref()
.map_or(true, |(_, cached_epoch)| *cached_epoch != slot_epoch)
.is_none_or(|(_, cached_epoch)| *cached_epoch != slot_epoch)
{
proposers_per_epoch = self
.get_proposers_by_epoch_from_cache(