Fix Nightly Clippy Warnings (backport #18065) (#18070)

* chore: cargo +nightly clippy --fix -Z unstable-options

(cherry picked from commit 6514096a67)

# Conflicts:
#	core/src/banking_stage.rs
#	core/src/cost_model.rs
#	core/src/cost_tracker.rs
#	core/src/execute_cost_table.rs
#	core/src/replay_stage.rs
#	core/src/tvu.rs
#	ledger-tool/src/main.rs
#	programs/bpf_loader/build.rs
#	rbpf-cli/src/main.rs
#	sdk/cargo-build-bpf/src/main.rs
#	sdk/cargo-test-bpf/src/main.rs
#	sdk/src/secp256k1_instruction.rs

* chore: cargo fmt

(cherry picked from commit 789f33e8db)

* Updates BPF program assert_instruction_count tests.

(cherry picked from commit c1e03f3410)

# Conflicts:
#	programs/bpf/tests/programs.rs

* Resolve conflicts

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2021-06-18 20:02:48 +00:00
committed by GitHub
parent c330016109
commit 0e7512a225
173 changed files with 1250 additions and 1056 deletions

View File

@@ -855,7 +855,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
read_lock_timer.stop();
read_lock_elapsed += read_lock_timer.as_us();
let mut latest_slot_timer = Measure::start("latest_slot");
if let Some(index) = self.latest_slot(Some(ancestors), &list_r, max_root) {
if let Some(index) = self.latest_slot(Some(ancestors), list_r, max_root) {
latest_slot_timer.stop();
latest_slot_elapsed += latest_slot_timer.as_us();
let mut load_account_timer = Measure::start("load_account");
@@ -1076,7 +1076,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
max: Option<Slot>,
) -> (SlotList<T>, RefCount) {
(
self.get_rooted_entries(&locked_account_entry.slot_list(), max),
self.get_rooted_entries(locked_account_entry.slot_list(), max),
locked_account_entry.ref_count().load(Ordering::Relaxed),
)
}
@@ -1093,7 +1093,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
if let Some(mut write_account_map_entry) = self.get_account_write_entry(pubkey) {
write_account_map_entry.slot_list_mut(|slot_list| {
slot_list.retain(|(slot, item)| {
let should_purge = slots_to_purge.contains(&slot);
let should_purge = slots_to_purge.contains(slot);
if should_purge {
reclaims.push((*slot, item.clone()));
false
@@ -1147,7 +1147,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
Some(inner) => inner,
None => self.roots_tracker.read().unwrap(),
};
if lock.roots.contains(&slot) {
if lock.roots.contains(slot) {
rv = Some(i);
current_max = *slot;
}
@@ -1402,7 +1402,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
) {
let roots_tracker = &self.roots_tracker.read().unwrap();
let newest_root_in_slot_list =
Self::get_newest_root_in_slot_list(&roots_tracker.roots, &slot_list, max_clean_root);
Self::get_newest_root_in_slot_list(&roots_tracker.roots, slot_list, max_clean_root);
let max_clean_root = max_clean_root.unwrap_or(roots_tracker.max_root);
let mut purged_slots: HashSet<Slot> = HashSet::new();
@@ -1865,7 +1865,7 @@ pub mod tests {
fn remove(&mut self, slot: &u64) -> bool {
let result = self.bitfield.remove(slot);
assert_eq!(result, self.hash_set.remove(slot));
assert!(!self.bitfield.contains(&slot));
assert!(!self.bitfield.contains(slot));
self.compare();
result
}
@@ -2130,7 +2130,7 @@ pub mod tests {
compare_internal(hashset, bitfield);
let clone = bitfield.clone();
compare_internal(hashset, &clone);
assert!(clone.eq(&bitfield));
assert!(clone.eq(bitfield));
assert_eq!(clone, *bitfield);
}
@@ -2181,8 +2181,8 @@ pub mod tests {
// remove the rest, including a call that removes slot again
for item in all.iter() {
assert!(tester.remove(&item));
assert!(!tester.remove(&item));
assert!(tester.remove(item));
assert!(!tester.remove(item));
}
let min = max + ((width * 2) as u64) + 3;
@@ -2457,15 +2457,15 @@ pub mod tests {
assert!(index.zero_lamport_pubkeys().is_empty());
let mut ancestors = Ancestors::default();
assert!(index.get(&pubkey, Some(&ancestors), None).is_none());
assert!(index.get(&pubkey, None, None).is_none());
assert!(index.get(pubkey, Some(&ancestors), None).is_none());
assert!(index.get(pubkey, None, None).is_none());
let mut num = 0;
index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1);
assert_eq!(num, 0);
ancestors.insert(slot, 0);
assert!(index.get(&pubkey, Some(&ancestors), None).is_some());
assert_eq!(index.ref_count_from_storage(&pubkey), 1);
assert!(index.get(pubkey, Some(&ancestors), None).is_some());
assert_eq!(index.ref_count_from_storage(pubkey), 1);
index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1);
assert_eq!(num, 1);
@@ -2478,15 +2478,15 @@ pub mod tests {
assert!(!index.zero_lamport_pubkeys().is_empty());
let mut ancestors = Ancestors::default();
assert!(index.get(&pubkey, Some(&ancestors), None).is_none());
assert!(index.get(&pubkey, None, None).is_none());
assert!(index.get(pubkey, Some(&ancestors), None).is_none());
assert!(index.get(pubkey, None, None).is_none());
let mut num = 0;
index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1);
assert_eq!(num, 0);
ancestors.insert(slot, 0);
assert!(index.get(&pubkey, Some(&ancestors), None).is_some());
assert_eq!(index.ref_count_from_storage(&pubkey), 0); // cached, so 0
assert!(index.get(pubkey, Some(&ancestors), None).is_some());
assert_eq!(index.ref_count_from_storage(pubkey), 0); // cached, so 0
index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1);
assert_eq!(num, 1);
}
@@ -3600,7 +3600,7 @@ pub mod tests {
// Both pubkeys will now be present in the index
check_secondary_index_mapping_correct(
&secondary_index,
secondary_index,
&[secondary_key1, secondary_key2],
&account_key,
);