Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

chore: clippy fixes #13579

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account-decoder/src/parse_account_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn parse_account_data(
) -> Result<ParsedAccount, ParseAccountError> {
let program_name = PARSABLE_PROGRAM_IDS
.get(program_id)
.ok_or_else(|| ParseAccountError::ProgramNotParsable)?;
.ok_or(ParseAccountError::ProgramNotParsable)?;
let additional_data = additional_data.unwrap_or_default();
let parsed_json = match program_name {
ParsableAccount::Config => serde_json::to_value(parse_config(data, pubkey)?)?,
Expand Down
2 changes: 2 additions & 0 deletions core/src/broadcast_stage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! A stage to broadcast data from a leader node to validators
#![allow(clippy::rc_buffer)]

use self::{
broadcast_fake_shreds_run::BroadcastFakeShredsRun, broadcast_metrics::*,
fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun,
Expand Down
2 changes: 2 additions & 0 deletions core/src/broadcast_stage/standard_broadcast_run.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::rc_buffer)]

use super::{
broadcast_utils::{self, ReceiveResults},
*,
Expand Down
3 changes: 2 additions & 1 deletion core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ impl ClusterInfo {
))
})
.collect();
#[allow(clippy::stable_sort_primitive)]
current_slots.sort();
let min_slot: Slot = current_slots
.iter()
Expand Down Expand Up @@ -1211,7 +1212,7 @@ impl ClusterInfo {
self.get_lowest_slot_for_node(&x.id, None, |lowest_slot, _| {
lowest_slot.lowest <= slot
})
.unwrap_or_else(|| /* fallback to legacy behavior */ true)
.unwrap_or(true /* fallback to legacy behavior */)
}
})
.collect();
Expand Down
2 changes: 2 additions & 0 deletions core/src/cluster_slots_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl ClusterSlotsService {
while let Ok(mut more) = completed_slots_receiver.try_recv() {
slots.append(&mut more);
}
#[allow(clippy::stable_sort_primitive)]
slots.sort();
if !slots.is_empty() {
cluster_info.push_epoch_slots(&slots);
Expand Down Expand Up @@ -163,6 +164,7 @@ impl ClusterSlotsService {
while let Ok(mut more) = completed_slots_receiver.try_recv() {
slots.append(&mut more);
}
#[allow(clippy::stable_sort_primitive)]
slots.sort();
slots.dedup();
if !slots.is_empty() {
Expand Down
7 changes: 2 additions & 5 deletions core/src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,7 @@ impl CrdsGossipPull {
for r in responses {
let owner = r.label().pubkey();
// Check if the crds value is older than the msg_timeout
if now
> r.wallclock()
.checked_add(self.msg_timeout)
.unwrap_or_else(|| 0)
if now > r.wallclock().checked_add(self.msg_timeout).unwrap_or(0)
|| now + self.msg_timeout < r.wallclock()
{
match &r.label() {
Expand All @@ -350,7 +347,7 @@ impl CrdsGossipPull {
let timeout = *timeouts
.get(&owner)
.unwrap_or_else(|| timeouts.get(&Pubkey::default()).unwrap());
if now > r.wallclock().checked_add(timeout).unwrap_or_else(|| 0)
if now > r.wallclock().checked_add(timeout).unwrap_or(0)
|| now + timeout < r.wallclock()
{
stats.timeout_count += 1;
Expand Down
9 changes: 2 additions & 7 deletions core/src/crds_gossip_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,7 @@ impl CrdsGossipPush {
now: u64,
) -> Result<Option<VersionedCrdsValue>, CrdsGossipError> {
self.num_total += 1;
if now
> value
.wallclock()
.checked_add(self.msg_timeout)
.unwrap_or_else(|| 0)
{
if now > value.wallclock().checked_add(self.msg_timeout).unwrap_or(0) {
return Err(CrdsGossipError::PushMessageTimeout);
}
if now + self.msg_timeout < value.wallclock() {
Expand Down Expand Up @@ -208,7 +203,7 @@ impl CrdsGossipPush {
/// push pull responses
pub fn push_pull_responses(&mut self, values: Vec<(CrdsValueLabel, Hash, u64)>, now: u64) {
for (label, value_hash, wc) in values {
if now > wc.checked_add(self.msg_timeout).unwrap_or_else(|| 0) {
if now > wc.checked_add(self.msg_timeout).unwrap_or(0) {
continue;
}
self.push_messages.insert(label, value_hash);
Expand Down
1 change: 1 addition & 0 deletions core/src/retransmit_stage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! The `retransmit_stage` retransmits shreds between validators
#![allow(clippy::rc_buffer)]

use crate::{
cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT},
Expand Down
1 change: 1 addition & 0 deletions core/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ impl RpcSubscriptions {
}

pub fn notify_roots(&self, mut rooted_slots: Vec<Slot>) {
#[allow(clippy::stable_sort_primitive)]
rooted_slots.sort();
rooted_slots.into_iter().for_each(|root| {
self.enqueue_notification(NotificationEntry::Root(root));
Expand Down
2 changes: 1 addition & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ fn main() {
println!("Ledger is empty");
} else {
let first = slots.first().unwrap();
let last = slots.last().unwrap_or_else(|| first);
let last = slots.last().unwrap_or(first);
if first != last {
println!("Ledger has data for slots {:?} to {:?}", first, last);
if all {
Expand Down
1 change: 1 addition & 0 deletions ledger/src/bigtable_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub async fn upload_confirmed_blocks(
.difference(&bigtable_slots)
.cloned()
.collect::<Vec<_>>();
#[allow(clippy::stable_sort_primitive)]
blocks_to_upload.sort();
blocks_to_upload
};
Expand Down
1 change: 1 addition & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ impl Blockstore {
.map(|(iter_slot, _)| iter_slot)
.take(timestamp_sample_range)
.collect();
#[allow(clippy::stable_sort_primitive)]
timestamp_slots.sort();
get_slots.stop();
datapoint_info!(
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/blockstore/blockstore_purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Blockstore {
.batch()
.expect("Database Error: Failed to get write batch");
// delete range cf is not inclusive
let to_slot = to_slot.checked_add(1).unwrap_or_else(|| std::u64::MAX);
let to_slot = to_slot.checked_add(1).unwrap_or(std::u64::MAX);

let mut delete_range_timer = Measure::start("delete_range");
let mut columns_purged = self
Expand Down
2 changes: 1 addition & 1 deletion programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ pub fn process_vote<S: std::hash::BuildHasher>(
vote.slots
.iter()
.max()
.ok_or_else(|| VoteError::EmptySlots)
.ok_or(VoteError::EmptySlots)
.and_then(|slot| vote_state.process_timestamp(*slot, timestamp))?;
}
vote_account.set_state(&VoteStateVersions::Current(Box::new(vote_state)))
Expand Down
3 changes: 1 addition & 2 deletions ramp-tps/src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl Results {
) -> Self {
let mut results: BTreeMap<Round, Vec<String>> = BTreeMap::new();
previous_results.drain().for_each(|(key, value)| {
if key.starts_with(ROUND_KEY_PREFIX) {
let round_str = &key[ROUND_KEY_PREFIX.len()..];
if let Some(round_str) = key.strip_prefix(ROUND_KEY_PREFIX) {
dbg!(round_str);
if let Ok(round) = u32::from_str(round_str) {
if round < start_round {
Expand Down
4 changes: 4 additions & 0 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,7 @@ impl AccountsDB {

pub fn generate_index(&self) {
let mut slots = self.storage.all_slots();
#[allow(clippy::stable_sort_primitive)]
slots.sort();

let mut last_log_update = Instant::now();
Expand Down Expand Up @@ -2950,6 +2951,7 @@ impl AccountsDB {

fn print_index(&self, label: &str) {
let mut roots: Vec<_> = self.accounts_index.all_roots();
#[allow(clippy::stable_sort_primitive)]
roots.sort();
info!("{}: accounts_index roots: {:?}", label, roots,);
for (pubkey, account_entry) in self.accounts_index.account_maps.read().unwrap().iter() {
Expand All @@ -2963,12 +2965,14 @@ impl AccountsDB {

fn print_count_and_status(&self, label: &str) {
let mut slots: Vec<_> = self.storage.all_slots();
#[allow(clippy::stable_sort_primitive)]
slots.sort();
info!("{}: count_and status for {} slots:", label, slots.len());
for slot in &slots {
let slot_stores = self.storage.get_slot_stores(*slot).unwrap();
let r_slot_stores = slot_stores.read().unwrap();
let mut ids: Vec<_> = r_slot_stores.keys().cloned().collect();
#[allow(clippy::stable_sort_primitive)]
ids.sort();
for id in &ids {
let entry = r_slot_stores.get(id).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ pub struct Bank {
bpf_compute_budget: Option<BpfComputeBudget>,

/// Builtin programs activated dynamically by feature
#[allow(clippy::rc_buffer)]
feature_builtins: Arc<Vec<(Builtin, Pubkey, ActivationType)>>,

/// Last time when the cluster info vote listener has synced with this bank
Expand Down Expand Up @@ -1081,6 +1082,7 @@ impl Bank {
}

let mut ancestors: Vec<_> = roots.into_iter().collect();
#[allow(clippy::stable_sort_primitive)]
ancestors.sort();
ancestors
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/status_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<T: Serialize + Clone> StatusCache<T> {
(
*slot,
self.roots.contains(slot),
self.slot_deltas.get(slot).unwrap_or_else(|| &empty).clone(),
self.slot_deltas.get(slot).unwrap_or(&empty).clone(),
)
})
.collect()
Expand Down
1 change: 1 addition & 0 deletions sdk/src/hard_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl HardForks {
} else {
self.hard_forks.push((new_slot, 1));
}
#[allow(clippy::stable_sort_primitive)]
self.hard_forks.sort();
}

Expand Down
2 changes: 1 addition & 1 deletion storage-bigtable/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl BigTable {
rows.into_iter()
.next()
.map(|r| r.1)
.ok_or_else(|| Error::RowNotFound)
.ok_or(Error::RowNotFound)
}

/// Store data for one or more `table` rows in the `family_name` Column family
Expand Down
2 changes: 1 addition & 1 deletion transaction-status/src/parse_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn parse(
) -> Result<ParsedInstruction, ParseInstructionError> {
let program_name = PARSABLE_PROGRAM_IDS
.get(program_id)
.ok_or_else(|| ParseInstructionError::ProgramNotParsable)?;
.ok_or(ParseInstructionError::ProgramNotParsable)?;
let parsed_json = match program_name {
ParsableProgram::SplMemo => parse_memo(instruction),
ParsableProgram::SplToken => serde_json::to_value(parse_token(instruction, account_keys)?)?,
Expand Down