New rust lints for rustc 1.64.0 (#3602)

## Issue Addressed
fixes lints from the last rust release

## Proposed Changes
Fix the lints, most of the lints by `clippy::question-mark` are false positives in the form of https://github.com/rust-lang/rust-clippy/issues/9518 so it's allowed for now

## Additional Info
This commit is contained in:
Divma
2022-09-23 03:52:46 +00:00
parent 9bd384a573
commit bd873e7162
10 changed files with 15 additions and 16 deletions

View File

@@ -809,7 +809,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
if let Some(request_root) = request_root_opt {
if let Ok(prev_root) = state.get_block_root(prev_slot) {
return Ok(Some((*prev_root != request_root).then(|| request_root)));
return Ok(Some((*prev_root != request_root).then_some(request_root)));
}
}
@@ -831,7 +831,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
slot: curr_slot,
});
}
Ok((curr_root != prev_root).then(|| curr_root))
Ok((curr_root != prev_root).then_some(curr_root))
} else {
Ok(None)
}
@@ -2871,7 +2871,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.pubkeys
.iter()
.zip(sync_aggregate.sync_committee_bits.iter())
.filter_map(|(pubkey, bit)| bit.then(|| pubkey))
.filter_map(|(pubkey, bit)| bit.then_some(pubkey))
.collect::<Vec<_>>();
validator_monitor.register_sync_aggregate_in_block(

View File

@@ -212,7 +212,7 @@ fn map_relevant_epochs_to_roots<T: BeaconChainTypes>(
let root = iter
.find_map(|next| match next {
Ok((root, slot)) => (slot == start_slot).then(|| Ok(root)),
Ok((root, slot)) => (slot == start_slot).then_some(Ok(root)),
Err(e) => Some(Err(format!("{:?}", e))),
})
.transpose()?
@@ -286,7 +286,7 @@ fn find_finalized_descendant_heads(
.filter_map(|(index, node)| {
(!nodes_referenced_as_parents.contains(&index)
&& fork_choice.is_descendant(finalized_root, node.root))
.then(|| HeadInfo {
.then_some(HeadInfo {
index,
root: node.root,
slot: node.slot,
@@ -306,7 +306,7 @@ fn update_store_justified_checkpoint(
.filter_map(|node| {
(node.finalized_checkpoint
== Some(persisted_fork_choice.fork_choice_store.finalized_checkpoint))
.then(|| node.justified_checkpoint)
.then_some(node.justified_checkpoint)
.flatten()
})
.max_by_key(|justified_checkpoint| justified_checkpoint.epoch)

View File

@@ -343,7 +343,7 @@ impl<T: BeaconChainTypes> VerifiedSyncContribution<T> {
let participant_pubkeys = sync_subcommittee_pubkeys
.into_iter()
.zip(contribution.aggregation_bits.iter())
.filter_map(|(pubkey, bit)| bit.then(|| pubkey))
.filter_map(|(pubkey, bit)| bit.then_some(pubkey))
.collect::<Vec<_>>();
// Ensure that all signatures are valid.

View File

@@ -1130,7 +1130,7 @@ where
selection_proof
.is_aggregator::<E>()
.expect("should determine aggregator")
.then(|| validator_index)
.then_some(validator_index)
})?;
let default = SyncCommitteeContribution::from_message(