Rust 1.95 lints (#9142)

N/A


  Adds lints for rust 1.95. Mostly cosmetic.
1. .zip(a.into_iter()) -> .zip(a) . Also a few more places where into_iter is not required
2. replace sort_by with sort_by_key
3. move if statements inside match block.
4. use checked_div instead of if statements. I think this is debatable in terms of being better, happy to remove it if others also feel its unnecessary


Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
Pawan Dhananjay
2026-04-17 05:20:20 +05:30
committed by GitHub
parent 794718e96b
commit 4cb3ffed8d
15 changed files with 142 additions and 176 deletions

View File

@@ -102,10 +102,8 @@ pub fn import<T: SlotClock + 'static, E: EthSpec>(
// Import each keystore. Some keystores may fail to be imported, so we record a status for each.
let mut statuses = Vec::with_capacity(request.keystores.len());
for (KeystoreJsonStr(keystore), password) in request
.keystores
.into_iter()
.zip(request.passwords.into_iter())
for (KeystoreJsonStr(keystore), password) in
request.keystores.into_iter().zip(request.passwords)
{
let pubkey_str = keystore.pubkey().to_string();

View File

@@ -1030,7 +1030,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore for LighthouseValidatorS
// Collect successfully signed attestations and log errors.
let mut signed_attestations = Vec::with_capacity(attestations.len());
for (result, att) in results.into_iter().zip(attestations.into_iter()) {
for (result, att) in results.into_iter().zip(attestations) {
match result {
Ok(()) => {
signed_attestations.push((

View File

@@ -471,8 +471,8 @@ impl<S: ValidatorStore, T: SlotClock + 'static> DutiesService<S, T> {
.voting_pubkeys(DoppelgangerStatus::only_safe);
self.attesters
.read()
.iter()
.filter_map(|(_, map)| map.get(&epoch))
.values()
.filter_map(|map| map.get(&epoch))
.map(|(_, duty_and_proof)| duty_and_proof)
.filter(|duty_and_proof| signing_pubkeys.contains(&duty_and_proof.duty.pubkey))
.count()
@@ -533,8 +533,8 @@ impl<S: ValidatorStore, T: SlotClock + 'static> DutiesService<S, T> {
self.attesters
.read()
.iter()
.filter_map(|(_, map)| map.get(&epoch))
.values()
.filter_map(|map| map.get(&epoch))
.map(|(_, duty_and_proof)| duty_and_proof)
.filter(|duty_and_proof| {
duty_and_proof.duty.slot == slot
@@ -983,8 +983,8 @@ async fn poll_beacon_attesters<S: ValidatorStore + 'static, T: SlotClock + 'stat
duties_service
.attesters
.read()
.iter()
.filter_map(|(_, map)| map.get(epoch))
.values()
.filter_map(|map| map.get(epoch))
.filter(|(_, duty_and_proof)| {
duty_and_proof
.subscription_slots