Fix Rust 1.83 Clippy lints (#6629)

* Fix Rust 1.83 Clippy lints

* Cargo fmt
This commit is contained in:
Michael Sproul
2024-11-29 13:23:54 +11:00
committed by GitHub
parent 38f5f665e1
commit fa6c4c02a3
35 changed files with 73 additions and 77 deletions

View File

@@ -306,7 +306,7 @@ pub struct VerifiedAggregatedAttestation<'a, T: BeaconChainTypes> {
indexed_attestation: IndexedAttestation<T::EthSpec>,
}
impl<'a, T: BeaconChainTypes> VerifiedAggregatedAttestation<'a, T> {
impl<T: BeaconChainTypes> VerifiedAggregatedAttestation<'_, T> {
pub fn into_indexed_attestation(self) -> IndexedAttestation<T::EthSpec> {
self.indexed_attestation
}
@@ -319,7 +319,7 @@ pub struct VerifiedUnaggregatedAttestation<'a, T: BeaconChainTypes> {
subnet_id: SubnetId,
}
impl<'a, T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'a, T> {
impl<T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'_, T> {
pub fn into_indexed_attestation(self) -> IndexedAttestation<T::EthSpec> {
self.indexed_attestation
}
@@ -327,7 +327,7 @@ impl<'a, T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'a, T> {
/// Custom `Clone` implementation is to avoid the restrictive trait bounds applied by the usual derive
/// macro.
impl<'a, T: BeaconChainTypes> Clone for IndexedUnaggregatedAttestation<'a, T> {
impl<T: BeaconChainTypes> Clone for IndexedUnaggregatedAttestation<'_, T> {
fn clone(&self) -> Self {
Self {
attestation: self.attestation,
@@ -353,7 +353,7 @@ pub trait VerifiedAttestation<T: BeaconChainTypes>: Sized {
}
}
impl<'a, T: BeaconChainTypes> VerifiedAttestation<T> for VerifiedAggregatedAttestation<'a, T> {
impl<T: BeaconChainTypes> VerifiedAttestation<T> for VerifiedAggregatedAttestation<'_, T> {
fn attestation(&self) -> AttestationRef<T::EthSpec> {
self.attestation()
}
@@ -363,7 +363,7 @@ impl<'a, T: BeaconChainTypes> VerifiedAttestation<T> for VerifiedAggregatedAttes
}
}
impl<'a, T: BeaconChainTypes> VerifiedAttestation<T> for VerifiedUnaggregatedAttestation<'a, T> {
impl<T: BeaconChainTypes> VerifiedAttestation<T> for VerifiedUnaggregatedAttestation<'_, T> {
fn attestation(&self) -> AttestationRef<T::EthSpec> {
self.attestation
}

View File

@@ -1112,6 +1112,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// ## Errors
///
/// May return a database error.
#[allow(clippy::type_complexity)]
pub fn get_blocks_checking_caches(
self: &Arc<Self>,
block_roots: Vec<Hash256>,
@@ -1127,6 +1128,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Ok(BeaconBlockStreamer::<T>::new(self, CheckCaches::Yes)?.launch_stream(block_roots))
}
#[allow(clippy::type_complexity)]
pub fn get_blocks(
self: &Arc<Self>,
block_roots: Vec<Hash256>,

View File

@@ -2072,6 +2072,7 @@ pub fn get_validator_pubkey_cache<T: BeaconChainTypes>(
///
/// The signature verifier is empty because it does not yet have any of this block's signatures
/// added to it. Use `Self::apply_to_signature_verifier` to apply the signatures.
#[allow(clippy::type_complexity)]
fn get_signature_verifier<'a, T: BeaconChainTypes>(
state: &'a BeaconState<T::EthSpec>,
validator_pubkey_cache: &'a ValidatorPubkeyCache<T>,

View File

@@ -107,8 +107,7 @@ fn get_sync_status<E: EthSpec>(
// Determine how many voting periods are contained in distance between
// now and genesis, rounding up.
let voting_periods_past =
(seconds_till_genesis + voting_period_duration - 1) / voting_period_duration;
let voting_periods_past = seconds_till_genesis.div_ceil(voting_period_duration);
// Return the start time of the current voting period*.
//

View File

@@ -113,7 +113,7 @@ pub trait SubsetItem {
fn root(&self) -> Result<Hash256, Error>;
}
impl<'a, E: EthSpec> SubsetItem for AttestationRef<'a, E> {
impl<E: EthSpec> SubsetItem for AttestationRef<'_, E> {
type Item = BitList<E::MaxValidatorsPerSlot>;
fn is_subset(&self, other: &Self::Item) -> bool {
match self {
@@ -159,7 +159,7 @@ impl<'a, E: EthSpec> SubsetItem for AttestationRef<'a, E> {
}
}
impl<'a, E: EthSpec> SubsetItem for &'a SyncCommitteeContribution<E> {
impl<E: EthSpec> SubsetItem for &SyncCommitteeContribution<E> {
type Item = BitVector<E::SyncSubcommitteeSize>;
fn is_subset(&self, other: &Self::Item) -> bool {
self.aggregation_bits.is_subset(other)

View File

@@ -48,8 +48,7 @@ pub(crate) struct BackoffStorage {
impl BackoffStorage {
fn heartbeats(d: &Duration, heartbeat_interval: &Duration) -> usize {
((d.as_nanos() + heartbeat_interval.as_nanos() - 1) / heartbeat_interval.as_nanos())
as usize
d.as_nanos().div_ceil(heartbeat_interval.as_nanos()) as usize
}
pub(crate) fn new(

View File

@@ -63,7 +63,7 @@ impl<'de> Deserialize<'de> for PeerIdSerialized {
// A wrapper struct that prints a dial error nicely.
struct ClearDialError<'a>(&'a DialError);
impl<'a> ClearDialError<'a> {
impl ClearDialError<'_> {
fn most_inner_error(err: &(dyn std::error::Error)) -> &(dyn std::error::Error) {
let mut current = err;
while let Some(source) = current.source() {
@@ -73,7 +73,7 @@ impl<'a> ClearDialError<'a> {
}
}
impl<'a> std::fmt::Display for ClearDialError<'a> {
impl std::fmt::Display for ClearDialError<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
match &self.0 {
DialError::Transport(errors) => {

View File

@@ -105,7 +105,7 @@ impl<E: EthSpec> SplitAttestation<E> {
}
}
impl<'a, E: EthSpec> CompactAttestationRef<'a, E> {
impl<E: EthSpec> CompactAttestationRef<'_, E> {
pub fn attestation_data(&self) -> AttestationData {
AttestationData {
slot: self.data.slot,

View File

@@ -56,7 +56,7 @@ where
}
}
impl<'a, F, E, Hot, Cold> Iterator for ChunkedVectorIter<'a, F, E, Hot, Cold>
impl<F, E, Hot, Cold> Iterator for ChunkedVectorIter<'_, F, E, Hot, Cold>
where
F: Field<E>,
E: EthSpec,

View File

@@ -149,8 +149,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for FrozenForwardsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for FrozenForwardsIterator<'_, E, Hot, Cold>
{
type Item = Result<(Hash256, Slot)>;
@@ -349,8 +349,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for HybridForwardsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for HybridForwardsIterator<'_, E, Hot, Cold>
{
type Item = Result<(Hash256, Slot)>;

View File

@@ -53,8 +53,8 @@ pub struct StateRootsIterator<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore
inner: RootsIterator<'a, E, Hot, Cold>,
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone
for StateRootsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone
for StateRootsIterator<'_, E, Hot, Cold>
{
fn clone(&self) -> Self {
Self {
@@ -77,8 +77,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> StateRootsIterator<'
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for StateRootsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for StateRootsIterator<'_, E, Hot, Cold>
{
type Item = Result<(Hash256, Slot), Error>;
@@ -101,8 +101,8 @@ pub struct BlockRootsIterator<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore
inner: RootsIterator<'a, E, Hot, Cold>,
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone
for BlockRootsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone
for BlockRootsIterator<'_, E, Hot, Cold>
{
fn clone(&self) -> Self {
Self {
@@ -136,8 +136,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BlockRootsIterator<'
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for BlockRootsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for BlockRootsIterator<'_, E, Hot, Cold>
{
type Item = Result<(Hash256, Slot), Error>;
@@ -155,9 +155,7 @@ pub struct RootsIterator<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>
slot: Slot,
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone
for RootsIterator<'a, E, Hot, Cold>
{
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Clone for RootsIterator<'_, E, Hot, Cold> {
fn clone(&self) -> Self {
Self {
store: self.store,
@@ -232,8 +230,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> RootsIterator<'a, E,
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for RootsIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for RootsIterator<'_, E, Hot, Cold>
{
/// (block_root, state_root, slot)
type Item = Result<(Hash256, Hash256, Slot), Error>;
@@ -295,8 +293,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for ParentRootBlockIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for ParentRootBlockIterator<'_, E, Hot, Cold>
{
type Item = Result<(Hash256, SignedBeaconBlock<E, BlindedPayload<E>>), Error>;
@@ -336,8 +334,8 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BlockIterator<'a, E,
}
}
impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for BlockIterator<'a, E, Hot, Cold>
impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> Iterator
for BlockIterator<'_, E, Hot, Cold>
{
type Item = Result<SignedBeaconBlock<E, BlindedPayload<E>>, Error>;