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

@ -153,7 +153,8 @@ lint:
-A clippy::derive_partial_eq_without_eq \ -A clippy::derive_partial_eq_without_eq \
-A clippy::from-over-into \ -A clippy::from-over-into \
-A clippy::upper-case-acronyms \ -A clippy::upper-case-acronyms \
-A clippy::vec-init-then-push -A clippy::vec-init-then-push \
-A clippy::question-mark
nightly-lint: nightly-lint:
cp .github/custom/clippy.toml . cp .github/custom/clippy.toml .

View File

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

View File

@ -212,7 +212,7 @@ fn map_relevant_epochs_to_roots<T: BeaconChainTypes>(
let root = iter let root = iter
.find_map(|next| match next { .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))), Err(e) => Some(Err(format!("{:?}", e))),
}) })
.transpose()? .transpose()?
@ -286,7 +286,7 @@ fn find_finalized_descendant_heads(
.filter_map(|(index, node)| { .filter_map(|(index, node)| {
(!nodes_referenced_as_parents.contains(&index) (!nodes_referenced_as_parents.contains(&index)
&& fork_choice.is_descendant(finalized_root, node.root)) && fork_choice.is_descendant(finalized_root, node.root))
.then(|| HeadInfo { .then_some(HeadInfo {
index, index,
root: node.root, root: node.root,
slot: node.slot, slot: node.slot,
@ -306,7 +306,7 @@ fn update_store_justified_checkpoint(
.filter_map(|node| { .filter_map(|node| {
(node.finalized_checkpoint (node.finalized_checkpoint
== Some(persisted_fork_choice.fork_choice_store.finalized_checkpoint)) == Some(persisted_fork_choice.fork_choice_store.finalized_checkpoint))
.then(|| node.justified_checkpoint) .then_some(node.justified_checkpoint)
.flatten() .flatten()
}) })
.max_by_key(|justified_checkpoint| justified_checkpoint.epoch) .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 let participant_pubkeys = sync_subcommittee_pubkeys
.into_iter() .into_iter()
.zip(contribution.aggregation_bits.iter()) .zip(contribution.aggregation_bits.iter())
.filter_map(|(pubkey, bit)| bit.then(|| pubkey)) .filter_map(|(pubkey, bit)| bit.then_some(pubkey))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// Ensure that all signatures are valid. // Ensure that all signatures are valid.

View File

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

View File

@ -2531,7 +2531,7 @@ pub fn serve<T: BeaconChainTypes>(
|| matches!(validator_status, ValidatorStatus::Active); || matches!(validator_status, ValidatorStatus::Active);
// Filter out validators who are not 'active' or 'pending'. // Filter out validators who are not 'active' or 'pending'.
is_active_or_pending.then(|| { is_active_or_pending.then_some({
( (
ProposerPreparationData { ProposerPreparationData {
validator_index: validator_index as u64, validator_index: validator_index as u64,

View File

@ -100,9 +100,7 @@ impl MerkleTree {
(Leaf(_), Leaf(_)) => return Err(MerkleTreeError::MerkleTreeFull), (Leaf(_), Leaf(_)) => return Err(MerkleTreeError::MerkleTreeFull),
// There is a right node so insert in right node // There is a right node so insert in right node
(Node(_, _, _), Node(_, _, _)) => { (Node(_, _, _), Node(_, _, _)) => {
if let Err(e) = right.push_leaf(elem, depth - 1) { right.push_leaf(elem, depth - 1)?;
return Err(e);
}
} }
// Both branches are zero, insert in left one // Both branches are zero, insert in left one
(Zero(_), Zero(_)) => { (Zero(_), Zero(_)) => {

View File

@ -326,7 +326,7 @@ mod test {
assert_eq!(fixed[0], 1); assert_eq!(fixed[0], 1);
assert_eq!(&fixed[0..1], &vec[0..1]); assert_eq!(&fixed[0..1], &vec[0..1]);
assert_eq!((&fixed[..]).len(), 8192); assert_eq!((fixed[..]).len(), 8192);
fixed[1] = 3; fixed[1] = 3;
assert_eq!(fixed[1], 3); assert_eq!(fixed[1], 3);

View File

@ -308,7 +308,7 @@ mod test {
assert_eq!(fixed[0], 1); assert_eq!(fixed[0], 1);
assert_eq!(&fixed[0..1], &vec[0..1]); assert_eq!(&fixed[0..1], &vec[0..1]);
assert_eq!((&fixed[..]).len(), 2); assert_eq!((fixed[..]).len(), 2);
fixed[1] = 3; fixed[1] = 3;
assert_eq!(fixed[1], 3); assert_eq!(fixed[1], 3);

View File

@ -294,7 +294,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
proposal_data.fee_recipient.and_then(|fee_recipient| { proposal_data.fee_recipient.and_then(|fee_recipient| {
proposal_data proposal_data
.builder_proposals .builder_proposals
.then(|| ValidatorRegistrationKey { .then_some(ValidatorRegistrationKey {
fee_recipient, fee_recipient,
gas_limit: proposal_data.gas_limit, gas_limit: proposal_data.gas_limit,
pubkey, pubkey,