patches clippy errors from new rust nightly release (#28028)
This commit is contained in:
parent
ca55fc8a05
commit
9ee53e594d
|
@ -36,7 +36,7 @@ fn get_retransmit_peers_deterministic(
|
|||
root_bank: &Bank,
|
||||
num_simulated_shreds: usize,
|
||||
) {
|
||||
let parent_offset = if slot == 0 { 0 } else { 1 };
|
||||
let parent_offset = u16::from(slot != 0);
|
||||
for i in 0..num_simulated_shreds {
|
||||
let index = i as u32;
|
||||
let shred = Shred::new_from_data(
|
||||
|
|
|
@ -1651,8 +1651,8 @@ impl BankingStage {
|
|||
let (units, times): (Vec<_>, Vec<_>) = execute_timings
|
||||
.details
|
||||
.per_program_timings
|
||||
.iter()
|
||||
.map(|(_program_id, program_timings)| {
|
||||
.values()
|
||||
.map(|program_timings| {
|
||||
(
|
||||
program_timings.accumulated_units,
|
||||
program_timings.accumulated_us,
|
||||
|
|
|
@ -393,14 +393,7 @@ impl RepairService {
|
|||
.chain(repair_stats.highest_shred.slot_pubkeys.iter())
|
||||
.chain(repair_stats.orphan.slot_pubkeys.iter())
|
||||
.map(|(slot, slot_repairs)| {
|
||||
(
|
||||
slot,
|
||||
slot_repairs
|
||||
.pubkey_repairs
|
||||
.iter()
|
||||
.map(|(_key, count)| count)
|
||||
.sum::<u64>(),
|
||||
)
|
||||
(slot, slot_repairs.pubkey_repairs.values().sum::<u64>())
|
||||
})
|
||||
.collect();
|
||||
info!("repair_stats: {:?}", slot_to_count);
|
||||
|
|
|
@ -275,7 +275,7 @@ pub mod test {
|
|||
let completed_shreds: Vec<Shred> = [0, 2, 4, 6]
|
||||
.iter()
|
||||
.map(|slot| {
|
||||
let parent_offset = if *slot == 0 { 0 } else { 1 };
|
||||
let parent_offset = u16::from(*slot != 0);
|
||||
let shred = Shred::new_from_data(
|
||||
*slot,
|
||||
last_shred as u32, // index
|
||||
|
|
|
@ -3865,10 +3865,7 @@ pub(crate) mod tests {
|
|||
vec![root, root + 1]
|
||||
);
|
||||
assert_eq!(
|
||||
epoch_slots_frozen_slots
|
||||
.into_iter()
|
||||
.map(|(slot, _hash)| slot)
|
||||
.collect::<Vec<Slot>>(),
|
||||
epoch_slots_frozen_slots.into_keys().collect::<Vec<Slot>>(),
|
||||
vec![root, root + 1]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -472,13 +472,9 @@ mod tests {
|
|||
fn count_non_discard(packet_batches: &[PacketBatch]) -> usize {
|
||||
packet_batches
|
||||
.iter()
|
||||
.map(|batch| {
|
||||
batch
|
||||
.iter()
|
||||
.map(|p| if p.meta.discard() { 0 } else { 1 })
|
||||
.sum::<usize>()
|
||||
})
|
||||
.sum::<usize>()
|
||||
.flatten()
|
||||
.filter(|p| !p.meta.discard())
|
||||
.count()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -276,8 +276,8 @@ mod tests {
|
|||
|
||||
let lamports = genesis_config
|
||||
.accounts
|
||||
.iter()
|
||||
.map(|(_, account)| account.lamports)
|
||||
.values()
|
||||
.map(|account| account.lamports)
|
||||
.sum::<u64>();
|
||||
|
||||
assert_eq!(500_000_000 * LAMPORTS_PER_SOL, lamports);
|
||||
|
|
|
@ -580,8 +580,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
|
||||
let issued_lamports = genesis_config
|
||||
.accounts
|
||||
.iter()
|
||||
.map(|(_key, account)| account.lamports)
|
||||
.values()
|
||||
.map(|account| account.lamports)
|
||||
.sum::<u64>();
|
||||
|
||||
add_genesis_accounts(&mut genesis_config, issued_lamports - faucet_lamports);
|
||||
|
|
|
@ -183,8 +183,8 @@ mod tests {
|
|||
assert_eq!(
|
||||
genesis_config
|
||||
.accounts
|
||||
.iter()
|
||||
.map(|(_pubkey, account)| account.lamports)
|
||||
.values()
|
||||
.map(|account| account.lamports)
|
||||
.sum::<u64>(),
|
||||
total_lamports,
|
||||
);
|
||||
|
|
|
@ -39,10 +39,10 @@ pub struct SlotStats {
|
|||
impl SlotStats {
|
||||
pub fn get_min_index_count(&self) -> usize {
|
||||
self.turbine_fec_set_index_counts
|
||||
.iter()
|
||||
.map(|(_, cnt)| *cnt)
|
||||
.values()
|
||||
.min()
|
||||
.unwrap_or(0)
|
||||
.copied()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn report(&self, slot: Slot) {
|
||||
|
|
|
@ -129,8 +129,8 @@ fn process_iftop_logs(matches: &ArgMatches) {
|
|||
}
|
||||
});
|
||||
let output: Vec<LogLine> = unique_latest_logs
|
||||
.into_iter()
|
||||
.map(|(_, l)| {
|
||||
.into_values()
|
||||
.map(|l| {
|
||||
if map_list.is_empty() {
|
||||
l
|
||||
} else {
|
||||
|
|
|
@ -416,7 +416,7 @@ impl<T: IndexValue> PreAllocatedAccountMapEntry<T> {
|
|||
storage: &Arc<BucketMapHolder<T>>,
|
||||
) -> AccountMapEntry<T> {
|
||||
let is_cached = account_info.is_cached();
|
||||
let ref_count = if is_cached { 0 } else { 1 };
|
||||
let ref_count = u64::from(!is_cached);
|
||||
let meta = AccountMapEntryMeta::new_dirty(storage, is_cached);
|
||||
Arc::new(AccountMapEntryInner::new(
|
||||
vec![(slot, account_info)],
|
||||
|
@ -2601,7 +2601,7 @@ pub mod tests {
|
|||
// verify the added entry matches expected
|
||||
{
|
||||
let entry = index.get_account_read_entry(&key).unwrap();
|
||||
assert_eq!(entry.ref_count(), if is_cached { 0 } else { 1 });
|
||||
assert_eq!(entry.ref_count(), u64::from(!is_cached));
|
||||
let expected = vec![(slot0, account_infos[0])];
|
||||
assert_eq!(entry.slot_list().to_vec(), expected);
|
||||
let new_entry: AccountMapEntry<_> = PreAllocatedAccountMapEntry::new(
|
||||
|
@ -4063,7 +4063,7 @@ pub mod tests {
|
|||
for expected in [false, true] {
|
||||
assert!(map.get_internal(&key, |entry| {
|
||||
// check refcount BEFORE the unref
|
||||
assert_eq!(if expected { 0 } else { 1 }, entry.unwrap().ref_count());
|
||||
assert_eq!(u64::from(!expected), entry.unwrap().ref_count());
|
||||
// first time, ref count was at 1, we can unref once. Unref should return false.
|
||||
// second time, ref count was at 0, it is an error to unref. Unref should return true
|
||||
assert_eq!(expected, entry.unwrap().unref());
|
||||
|
|
|
@ -16936,7 +16936,7 @@ pub(crate) mod tests {
|
|||
load_vote_and_stake_accounts(&bank).vote_with_stake_delegations_map;
|
||||
assert_eq!(
|
||||
vote_and_stake_accounts.len(),
|
||||
if check_owner_change { 0 } else { 1 }
|
||||
usize::from(!check_owner_change)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,16 +164,11 @@ impl CostTracker {
|
|||
}
|
||||
|
||||
fn find_costliest_account(&self) -> (Pubkey, u64) {
|
||||
let mut costliest_account = Pubkey::default();
|
||||
let mut costliest_account_cost = 0;
|
||||
for (key, cost) in self.cost_by_writable_accounts.iter() {
|
||||
if *cost > costliest_account_cost {
|
||||
costliest_account = *key;
|
||||
costliest_account_cost = *cost;
|
||||
}
|
||||
}
|
||||
|
||||
(costliest_account, costliest_account_cost)
|
||||
self.cost_by_writable_accounts
|
||||
.iter()
|
||||
.max_by_key(|(_, &cost)| cost)
|
||||
.map(|(&pubkey, &cost)| (pubkey, cost))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn would_fit(&self, tx_cost: &TransactionCost) -> Result<(), CostTrackerError> {
|
||||
|
@ -315,9 +310,9 @@ impl CostTracker {
|
|||
/// count number of none-zero CU accounts
|
||||
fn number_of_accounts(&self) -> usize {
|
||||
self.cost_by_writable_accounts
|
||||
.iter()
|
||||
.map(|(_key, units)| usize::from(*units > 0))
|
||||
.sum()
|
||||
.values()
|
||||
.filter(|units| **units > 0)
|
||||
.count()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ impl ExecuteCostTable {
|
|||
if self.table.is_empty() {
|
||||
self.get_default_compute_unit_limit()
|
||||
} else {
|
||||
self.table.iter().map(|(_, value)| value).sum::<u64>() / self.get_count() as u64
|
||||
self.table.values().sum::<u64>() / self.get_count() as u64
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -866,7 +866,7 @@ pub mod tests {
|
|||
);
|
||||
let partition_index_passed_pubkey = partition_from_pubkey <= partition_index;
|
||||
let expected_rent_epoch =
|
||||
rent_collector.epoch - if partition_index_passed_pubkey { 0 } else { 1 };
|
||||
rent_collector.epoch - u64::from(!partition_index_passed_pubkey);
|
||||
let expected_rent_collection_slot_max_epoch = first_slot_in_max_epoch
|
||||
+ partition_from_pubkey
|
||||
- if partition_index_passed_pubkey {
|
||||
|
@ -1090,7 +1090,7 @@ pub mod tests {
|
|||
partition_index_from_max_slot,
|
||||
first_slot_in_max_epoch,
|
||||
expected_rent_collection_slot_max_epoch,
|
||||
rent_epoch: rent_collector.epoch - if hit_this_epoch { 0 } else {1},
|
||||
rent_epoch: rent_collector.epoch - u64::from(!hit_this_epoch),
|
||||
}),
|
||||
"partition_index_from_max_slot: {}, epoch: {}, hit_this_epoch: {}, skipped_slot: {}",
|
||||
partition_index_from_max_slot,
|
||||
|
|
|
@ -1057,7 +1057,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
|||
let mut count = 0;
|
||||
insert.into_iter().for_each(|(slot, k, v)| {
|
||||
let entry = (slot, v);
|
||||
let new_ref_count = if v.is_cached() { 0 } else { 1 };
|
||||
let new_ref_count = u64::from(!v.is_cached());
|
||||
disk.update(&k, |current| {
|
||||
match current {
|
||||
Some((current_slot_list, mut ref_count)) => {
|
||||
|
|
|
@ -154,9 +154,7 @@ impl<T: Serialize + Clone> StatusCache<T> {
|
|||
key: K,
|
||||
ancestors: &Ancestors,
|
||||
) -> Option<(Slot, T)> {
|
||||
let mut keys = vec![];
|
||||
let mut val: Vec<_> = self.cache.iter().map(|(k, _)| *k).collect();
|
||||
keys.append(&mut val);
|
||||
let keys: Vec<_> = self.cache.keys().copied().collect();
|
||||
|
||||
for blockhash in keys.iter() {
|
||||
trace!("get_status_any_blockhash: trying {}", blockhash);
|
||||
|
|
|
@ -170,7 +170,6 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::blacklisted_name)]
|
||||
fn test_dyn_keypairs_by_ref_compile() {
|
||||
let foo = Foo {};
|
||||
let bar = Bar {};
|
||||
|
|
|
@ -975,11 +975,7 @@ impl LedgerStorage {
|
|||
.collect();
|
||||
|
||||
let tx_deletion_rows = if !expected_tx_infos.is_empty() {
|
||||
let signatures = expected_tx_infos
|
||||
.iter()
|
||||
.map(|(signature, _info)| signature)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
let signatures = expected_tx_infos.keys().cloned().collect::<Vec<_>>();
|
||||
let fetched_tx_infos: HashMap<String, std::result::Result<UploadedTransaction, _>> =
|
||||
self.connection
|
||||
.get_bincode_cells_with_retry::<TransactionInfo>("tx", &signatures)
|
||||
|
|
|
@ -500,7 +500,7 @@ impl TpuClient {
|
|||
}
|
||||
}
|
||||
|
||||
transactions = pending_transactions.into_iter().map(|(_k, v)| v).collect();
|
||||
transactions = pending_transactions.into_values().collect();
|
||||
progress_bar.println(format!(
|
||||
"Blockhash expired. {} retries remaining",
|
||||
expired_blockhash_retries
|
||||
|
|
Loading…
Reference in New Issue