From a2e7bdf50ac5e1d4c633f64f6362028b4164c003 Mon Sep 17 00:00:00 2001 From: Brennan Watt Date: Wed, 17 Aug 2022 15:48:33 -0700 Subject: [PATCH] Rust v1.63.0 (#27148) * Upgrade to Rust v1.63.0 * Add nightly_clippy_allows * Resolve some new clippy nightly lints * Increase QUIC packets completion timeout Co-authored-by: Michael Vines --- account-decoder/src/parse_address_lookup_table.rs | 2 +- banks-server/src/banks_server.rs | 10 +++------- ci/docker-rust-nightly/Dockerfile | 2 +- ci/docker-rust/Dockerfile | 2 +- ci/rust-version.sh | 4 ++-- ci/test-checks.sh | 14 ++++++++++++++ client/tests/quic_client.rs | 2 +- core/src/banking_stage.rs | 2 +- core/src/sigverify_shreds.rs | 2 +- frozen-abi/src/abi_example.rs | 2 +- gossip/src/crds_gossip_pull.rs | 2 +- ledger/src/bigtable_upload.rs | 2 +- ledger/src/blockstore.rs | 2 +- ledger/src/blockstore_meta.rs | 2 +- ledger/src/shred.rs | 2 +- ledger/src/shred/shred_code.rs | 2 +- local-cluster/src/local_cluster.rs | 2 +- perf/src/sigverify.rs | 7 +------ poh/src/poh_recorder.rs | 2 +- rpc/src/rpc.rs | 6 ++---- rpc/src/rpc_subscriptions.rs | 5 +---- runtime/src/account_rent_state.rs | 2 +- runtime/src/accounts.rs | 2 +- runtime/src/accounts_db.rs | 8 ++++---- runtime/src/bank.rs | 12 ++++++------ runtime/src/expected_rent_collection.rs | 8 ++++---- runtime/src/hardened_unpack.rs | 2 +- runtime/src/in_mem_accounts_index.rs | 2 ++ runtime/src/serde_snapshot.rs | 4 ++-- runtime/src/serde_snapshot/newer.rs | 4 ++-- runtime/src/serde_snapshot/tests.rs | 2 +- runtime/src/snapshot_minimizer.rs | 2 +- runtime/src/snapshot_utils.rs | 2 +- runtime/src/storable_accounts.rs | 2 +- runtime/src/system_instruction_processor.rs | 2 +- sdk/program/src/message/compiled_keys.rs | 10 +++++----- sdk/program/src/nonce/state/mod.rs | 2 +- sdk/program/src/stake/tools.rs | 2 +- streamer/src/streamer.rs | 2 +- validator/src/bootstrap.rs | 6 ++---- zk-token-sdk/src/instruction/close_account.rs | 2 +- zk-token-sdk/src/instruction/withdraw.rs | 2 +- 42 files changed, 78 insertions(+), 78 deletions(-) diff --git a/account-decoder/src/parse_address_lookup_table.rs b/account-decoder/src/parse_address_lookup_table.rs index 26955d74a7..ca461f2636 100644 --- a/account-decoder/src/parse_address_lookup_table.rs +++ b/account-decoder/src/parse_address_lookup_table.rs @@ -19,7 +19,7 @@ pub fn parse_address_lookup_table( }) } -#[derive(Debug, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase", tag = "type", content = "info")] pub enum LookupTableAccountType { Uninitialized, diff --git a/banks-server/src/banks_server.rs b/banks-server/src/banks_server.rs index c73844d257..a4b65601c3 100644 --- a/banks-server/src/banks_server.rs +++ b/banks-server/src/banks_server.rs @@ -153,13 +153,9 @@ fn verify_transaction( transaction: &Transaction, feature_set: &Arc, ) -> transaction::Result<()> { - if let Err(err) = transaction.verify() { - Err(err) - } else if let Err(err) = transaction.verify_precompiles(feature_set) { - Err(err) - } else { - Ok(()) - } + transaction.verify()?; + transaction.verify_precompiles(feature_set)?; + Ok(()) } fn simulate_transaction( diff --git a/ci/docker-rust-nightly/Dockerfile b/ci/docker-rust-nightly/Dockerfile index fff0f366d3..12aeff7e5e 100644 --- a/ci/docker-rust-nightly/Dockerfile +++ b/ci/docker-rust-nightly/Dockerfile @@ -1,4 +1,4 @@ -FROM solanalabs/rust:1.60.0 +FROM solanalabs/rust:1.63.0 ARG date RUN set -x \ diff --git a/ci/docker-rust/Dockerfile b/ci/docker-rust/Dockerfile index 6805f85fcd..a256d308d9 100644 --- a/ci/docker-rust/Dockerfile +++ b/ci/docker-rust/Dockerfile @@ -1,6 +1,6 @@ # Note: when the rust version is changed also modify # ci/rust-version.sh to pick up the new image tag -FROM rust:1.60.0 +FROM rust:1.63.0 # Add Google Protocol Buffers for Libra's metrics library. ENV PROTOC_VERSION 3.8.0 diff --git a/ci/rust-version.sh b/ci/rust-version.sh index dc3570fa93..792863c328 100644 --- a/ci/rust-version.sh +++ b/ci/rust-version.sh @@ -18,13 +18,13 @@ if [[ -n $RUST_STABLE_VERSION ]]; then stable_version="$RUST_STABLE_VERSION" else - stable_version=1.60.0 + stable_version=1.63.0 fi if [[ -n $RUST_NIGHTLY_VERSION ]]; then nightly_version="$RUST_NIGHTLY_VERSION" else - nightly_version=2022-04-01 + nightly_version=2022-08-12 fi diff --git a/ci/test-checks.sh b/ci/test-checks.sh index 72c174395b..65e5e6271a 100755 --- a/ci/test-checks.sh +++ b/ci/test-checks.sh @@ -65,11 +65,25 @@ fi _ ci/order-crates-for-publishing.py +nightly_clippy_allows=( + # This lint occurs all over the code base + "--allow=clippy::significant_drop_in_scrutinee" + + # The prost crate, used by solana-storage-proto, generates Rust source that + # triggers this lint. Need to resolve upstream in prost + "--allow=clippy::derive_partial_eq_without_eq" + + # This link seems to incorrectly trigger in + # `programs/bpf_loader/src/syscalls/{lib,cpi}.rs` + "--allow=clippy::explicit_auto_deref" +) + # -Z... is needed because of clippy bug: https://github.com/rust-lang/rust-clippy/issues/4612 # run nightly clippy for `sdk/` as there's a moderate amount of nightly-only code there _ scripts/cargo-for-all-lock-files.sh -- nightly clippy -Zunstable-options --all-targets -- \ --deny=warnings \ --deny=clippy::integer_arithmetic \ + "${nightly_clippy_allows[@]}" _ scripts/cargo-for-all-lock-files.sh -- nightly sort --workspace --check _ scripts/cargo-for-all-lock-files.sh -- nightly fmt --all -- --check diff --git a/client/tests/quic_client.rs b/client/tests/quic_client.rs index 980476aee7..1c5348177d 100644 --- a/client/tests/quic_client.rs +++ b/client/tests/quic_client.rs @@ -27,7 +27,7 @@ mod tests { let mut all_packets = vec![]; let now = Instant::now(); let mut total_packets: usize = 0; - while now.elapsed().as_secs() < 5 { + while now.elapsed().as_secs() < 10 { if let Ok(packets) = receiver.recv_timeout(Duration::from_secs(1)) { total_packets = total_packets.saturating_add(packets.len()); all_packets.push(packets) diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 2547c00f94..1c3e95e2bd 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -1335,7 +1335,7 @@ impl BankingStage { ); retryable_transaction_indexes.extend(execution_results.iter().enumerate().filter_map( - |(index, execution_result)| execution_result.was_executed().then(|| index), + |(index, execution_result)| execution_result.was_executed().then_some(index), )); return ExecuteAndCommitTransactionsOutput { diff --git a/core/src/sigverify_shreds.rs b/core/src/sigverify_shreds.rs index f9a50ab8b2..f1f08ec671 100644 --- a/core/src/sigverify_shreds.rs +++ b/core/src/sigverify_shreds.rs @@ -151,7 +151,7 @@ fn get_slot_leaders( let leader = leaders.entry(slot).or_insert_with(|| { let leader = leader_schedule_cache.slot_leader_at(slot, Some(bank))?; // Discard the shred if the slot leader is the node itself. - (&leader != self_pubkey).then(|| leader) + (&leader != self_pubkey).then_some(leader) }); if leader.is_none() { packet.meta.set_discard(true); diff --git a/frozen-abi/src/abi_example.rs b/frozen-abi/src/abi_example.rs index e0dfa50b8a..2e1bdbcac1 100644 --- a/frozen-abi/src/abi_example.rs +++ b/frozen-abi/src/abi_example.rs @@ -411,7 +411,7 @@ lazy_static! { impl AbiExample for &Vec { fn example() -> Self { info!("AbiExample for (&Vec): {}", type_name::()); - &*VEC_U8 + &VEC_U8 } } diff --git a/gossip/src/crds_gossip_pull.rs b/gossip/src/crds_gossip_pull.rs index 2780bf7dab..04df91227b 100644 --- a/gossip/src/crds_gossip_pull.rs +++ b/gossip/src/crds_gossip_pull.rs @@ -256,7 +256,7 @@ impl CrdsGossipPull { if let Some(ping) = ping { pings.push((peer.gossip, ping)); } - check.then(|| (weight, peer)) + check.then_some((weight, peer)) }) .unzip() }; diff --git a/ledger/src/bigtable_upload.rs b/ledger/src/bigtable_upload.rs index f43b07db12..c8cdef587b 100644 --- a/ledger/src/bigtable_upload.rs +++ b/ledger/src/bigtable_upload.rs @@ -60,7 +60,7 @@ pub async fn upload_confirmed_blocks( starting_slot, err ) })? - .map_while(|slot| (slot <= ending_slot).then(|| slot)) + .map_while(|slot| (slot <= ending_slot).then_some(slot)) .collect(); if blockstore_slots.is_empty() { diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index acacf9d842..66340b5cb0 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -3145,7 +3145,7 @@ impl Blockstore { } .expect("fetch from DuplicateSlots column family failed")?; let new_shred = Shred::new_from_serialized_shred(payload).unwrap(); - (existing_shred != *new_shred.payload()).then(|| existing_shred) + (existing_shred != *new_shred.payload()).then_some(existing_shred) } pub fn has_duplicate_shreds_in_slot(&self, slot: Slot) -> bool { diff --git a/ledger/src/blockstore_meta.rs b/ledger/src/blockstore_meta.rs index 65101fe983..5cacf78198 100644 --- a/ledger/src/blockstore_meta.rs +++ b/ledger/src/blockstore_meta.rs @@ -61,7 +61,7 @@ mod serde_compat { D: Deserializer<'de>, { let val = u64::deserialize(deserializer)?; - Ok((val != u64::MAX).then(|| val)) + Ok((val != u64::MAX).then_some(val)) } } diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs index e17055b1e7..bef3df7251 100644 --- a/ledger/src/shred.rs +++ b/ledger/src/shred.rs @@ -613,7 +613,7 @@ pub mod layout { merkle::ShredData::get_signed_message_range(proof_size)? } }; - (shred.len() <= range.end).then(|| range) + (shred.len() <= range.end).then_some(range) } pub(crate) fn get_reference_tick(shred: &[u8]) -> Result { diff --git a/ledger/src/shred/shred_code.rs b/ledger/src/shred/shred_code.rs index 538bb25427..1fe3fef026 100644 --- a/ledger/src/shred/shred_code.rs +++ b/ledger/src/shred/shred_code.rs @@ -119,7 +119,7 @@ pub(super) fn erasure_shard_index(shred: &T) -> Option let position = usize::from(coding_header.position); let fec_set_size = num_data_shreds.checked_add(num_coding_shreds)?; let index = position.checked_add(num_data_shreds)?; - (index < fec_set_size).then(|| index) + (index < fec_set_size).then_some(index) } pub(super) fn sanitize(shred: &T) -> Result<(), Error> { diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index f7b6864705..0f1ca19f87 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -319,7 +319,7 @@ impl LocalCluster { }) .collect(); for (stake, validator_config, (key, _)) in izip!( - (&config.node_stakes[1..]).iter(), + config.node_stakes[1..].iter(), config.validator_configs[1..].iter(), validator_keys[1..].iter(), ) { diff --git a/perf/src/sigverify.rs b/perf/src/sigverify.rs index aee1b310dd..1e40d29adc 100644 --- a/perf/src/sigverify.rs +++ b/perf/src/sigverify.rs @@ -830,12 +830,7 @@ mod tests { pub fn memfind(a: &[A], b: &[A]) -> Option { assert!(a.len() >= b.len()); let end = a.len() - b.len() + 1; - for i in 0..end { - if a[i..i + b.len()] == b[..] { - return Some(i); - } - } - None + (0..end).find(|&i| a[i..i + b.len()] == b[..]) } #[test] diff --git a/poh/src/poh_recorder.rs b/poh/src/poh_recorder.rs index aef2d7393e..d6c85c3fdf 100644 --- a/poh/src/poh_recorder.rs +++ b/poh/src/poh_recorder.rs @@ -505,7 +505,7 @@ impl PohRecorder { start: Arc::new(Instant::now()), min_tick_height: bank.tick_height(), max_tick_height: bank.max_tick_height(), - transaction_index: track_transaction_indexes.then(|| 0), + transaction_index: track_transaction_indexes.then_some(0), }; trace!("new working bank"); assert_eq!(working_bank.bank.ticks_per_slot(), self.ticks_per_slot()); diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index fdf72d8f5d..9cad136b58 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -129,7 +129,7 @@ fn new_response(bank: &Bank, value: T) -> RpcResponse { /// Wrapper for rpc return types of methods that provide responses both with and without context. /// Main purpose of this is to fix methods that lack context information in their return type, /// without breaking backwards compatibility. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum OptionalContext { Context(RpcResponse), @@ -3646,9 +3646,7 @@ pub mod rpc_full { } if !skip_preflight { - if let Err(e) = verify_transaction(&transaction, &preflight_bank.feature_set) { - return Err(e); - } + verify_transaction(&transaction, &preflight_bank.feature_set)?; match meta.health.check() { RpcHealthStatus::Ok => (), diff --git a/rpc/src/rpc_subscriptions.rs b/rpc/src/rpc_subscriptions.rs index bd9fe33746..896b6a9ad5 100644 --- a/rpc/src/rpc_subscriptions.rs +++ b/rpc/src/rpc_subscriptions.rs @@ -1001,10 +1001,7 @@ impl RpcSubscriptions { let mut slots_to_notify: Vec<_> = (*w_last_unnotified_slot..slot).collect(); let ancestors = bank.proper_ancestors_set(); - slots_to_notify = slots_to_notify - .into_iter() - .filter(|slot| ancestors.contains(slot)) - .collect(); + slots_to_notify.retain(|slot| ancestors.contains(slot)); slots_to_notify.push(slot); for s in slots_to_notify { // To avoid skipping a slot that fails this condition, diff --git a/runtime/src/account_rent_state.rs b/runtime/src/account_rent_state.rs index 629502caf4..74cbc5b81a 100644 --- a/runtime/src/account_rent_state.rs +++ b/runtime/src/account_rent_state.rs @@ -104,7 +104,7 @@ pub(crate) fn check_rent_state( .get_account_at_index(index) .expect(expect_msg) .borrow(), - include_account_index_in_err.then(|| index), + include_account_index_in_err.then_some(index), prevent_crediting_accounts_that_end_rent_paying, )?; } diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 86d14aaf7b..ade9d327ba 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -440,7 +440,7 @@ impl Accounts { payer_account, feature_set .is_active(&feature_set::include_account_index_in_rent_error::ID) - .then(|| payer_index), + .then_some(payer_index), feature_set .is_active(&feature_set::prevent_crediting_accounts_that_end_rent_paying::id()), ) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index caa4cc77f3..4c789751a2 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -2174,7 +2174,7 @@ impl AccountsDb { // figure out how many ancient accounts have been reclaimed let old_reclaims = reclaims .iter() - .filter_map(|(slot, _)| (slot < &one_epoch_old).then(|| 1)) + .filter_map(|(slot, _)| (slot < &one_epoch_old).then_some(1)) .sum(); ancient_account_cleans.fetch_add(old_reclaims, Ordering::Relaxed); reclaims @@ -2392,7 +2392,7 @@ impl AccountsDb { .iter() .filter_map(|entry| { let slot = *entry.key(); - (slot <= max_slot).then(|| slot) + (slot <= max_slot).then_some(slot) }) .collect() } @@ -3676,7 +3676,7 @@ impl AccountsDb { ) -> Option { self.get_storages_for_slot(slot).and_then(|all_storages| { self.should_move_to_ancient_append_vec(&all_storages, current_ancient, slot) - .then(|| all_storages) + .then_some(all_storages) }) } @@ -5309,7 +5309,7 @@ impl AccountsDb { // with the same slot. let is_being_flushed = !currently_contended_slots.insert(*remove_slot); // If the cache is currently flushing this slot, add it to the list - is_being_flushed.then(|| remove_slot) + is_being_flushed.then_some(remove_slot) }) .cloned() .collect(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 8428400f7c..4aea09da2d 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -2285,7 +2285,7 @@ impl Bank { hash: *self.hash.read().unwrap(), parent_hash: self.parent_hash, parent_slot: self.parent_slot, - hard_forks: &*self.hard_forks, + hard_forks: &self.hard_forks, transaction_count: self.transaction_count.load(Relaxed), tick_height: self.tick_height.load(Relaxed), signature_count: self.signature_count.load(Relaxed), @@ -3293,7 +3293,7 @@ impl Bank { let vote_state = account.vote_state(); let vote_state = vote_state.as_ref().ok()?; let slot_delta = self.slot().checked_sub(vote_state.last_timestamp.slot)?; - (slot_delta <= slots_per_epoch).then(|| { + (slot_delta <= slots_per_epoch).then_some({ ( *pubkey, ( @@ -3963,10 +3963,10 @@ impl Bank { } /// Prepare a transaction batch without locking accounts for transaction simulation. - pub(crate) fn prepare_simulation_batch<'a>( - &'a self, + pub(crate) fn prepare_simulation_batch( + &self, transaction: SanitizedTransaction, - ) -> TransactionBatch<'a, '_> { + ) -> TransactionBatch<'_, '_> { let tx_account_lock_limit = self.get_transaction_account_lock_limit(); let lock_result = transaction .get_account_locks(tx_account_lock_limit) @@ -4367,7 +4367,7 @@ impl Bank { self.feature_set.clone(), compute_budget, timings, - &*self.sysvar_cache.read().unwrap(), + &self.sysvar_cache.read().unwrap(), blockhash, lamports_per_signature, prev_accounts_data_len, diff --git a/runtime/src/expected_rent_collection.rs b/runtime/src/expected_rent_collection.rs index d049430933..bd6a6bb484 100644 --- a/runtime/src/expected_rent_collection.rs +++ b/runtime/src/expected_rent_collection.rs @@ -684,7 +684,7 @@ pub mod tests { ); assert_eq!( result, - (!leave_alone).then(|| ExpectedRentCollection { + (!leave_alone).then_some(ExpectedRentCollection { partition_from_pubkey, epoch_of_max_storage_slot: rent_collector.epoch, partition_index_from_max_slot: partition_index_max_inclusive, @@ -712,7 +712,7 @@ pub mod tests { ); assert_eq!( result, - (!greater).then(|| ExpectedRentCollection { + (!greater).then_some(ExpectedRentCollection { partition_from_pubkey, epoch_of_max_storage_slot: rent_collector.epoch, partition_index_from_max_slot: partition_index_max_inclusive, @@ -909,7 +909,7 @@ pub mod tests { ); assert_eq!( result, - (account_rent_epoch != 0).then(|| ExpectedRentCollection { + (account_rent_epoch != 0).then_some(ExpectedRentCollection { partition_from_pubkey, epoch_of_max_storage_slot: rent_collector.epoch + 1, partition_index_from_max_slot: partition_index_max_inclusive, @@ -1084,7 +1084,7 @@ pub mod tests { }; assert_eq!( result, - some_expected.then(|| ExpectedRentCollection { + some_expected.then_some(ExpectedRentCollection { partition_from_pubkey, epoch_of_max_storage_slot: rent_collector.epoch, partition_index_from_max_slot, diff --git a/runtime/src/hardened_unpack.rs b/runtime/src/hardened_unpack.rs index e3af855216..ac1c231673 100644 --- a/runtime/src/hardened_unpack.rs +++ b/runtime/src/hardened_unpack.rs @@ -384,7 +384,7 @@ where .map(|path_buf| path_buf.as_path()) { Some(path) => { - accounts_path_processor(*file, path); + accounts_path_processor(file, path); UnpackPath::Valid(path) } None => UnpackPath::Invalid, diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index b252499267..c04e0eed10 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -1418,6 +1418,8 @@ impl<'a> FlushGuard<'a> { #[must_use = "if unused, the `flushing` flag will immediately clear"] fn lock(flushing: &'a AtomicBool) -> Option { let already_flushing = flushing.swap(true, Ordering::AcqRel); + // Eager evaluation here would result in dropping Self and clearing flushing flag + #[allow(clippy::unnecessary_lazy_evaluations)] (!already_flushing).then(|| Self { flushing }) } } diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index 5b42208d04..90d0c6db2e 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -65,7 +65,7 @@ pub(crate) enum SerdeStyle { const MAX_STREAM_SIZE: u64 = 32 * 1024 * 1024 * 1024; -#[derive(Clone, Debug, Default, Deserialize, Serialize, AbiExample, PartialEq)] +#[derive(Clone, Debug, Default, Deserialize, Serialize, AbiExample, PartialEq, Eq)] pub struct AccountsDbFields( HashMap>, StoredMetaWriteVersion, @@ -120,7 +120,7 @@ impl SnapshotAccountsDbFields { // There must not be any overlap in the slots of storages between the full snapshot and the incremental snapshot incremental_snapshot_storages .iter() - .all(|storage_entry| !full_snapshot_storages.contains_key(storage_entry.0)).then(|| ()).ok_or_else(|| { + .all(|storage_entry| !full_snapshot_storages.contains_key(storage_entry.0)).then_some(()).ok_or_else(|| { io::Error::new(io::ErrorKind::InvalidData, "Snapshots are incompatible: There are storages for the same slot in both the full snapshot and the incremental snapshot!") })?; diff --git a/runtime/src/serde_snapshot/newer.rs b/runtime/src/serde_snapshot/newer.rs index 512737106a..ab27961bf2 100644 --- a/runtime/src/serde_snapshot/newer.rs +++ b/runtime/src/serde_snapshot/newer.rs @@ -201,7 +201,7 @@ impl<'a> TypeContext<'a> for Context { ( SerializableVersionedBank::from(fields), SerializableAccountsDb::<'a, Self> { - accounts_db: &*serializable_bank.bank.rc.accounts.accounts_db, + accounts_db: &serializable_bank.bank.rc.accounts.accounts_db, slot: serializable_bank.bank.rc.slot, account_storage_entries: serializable_bank.snapshot_storages, phantom: std::marker::PhantomData::default(), @@ -228,7 +228,7 @@ impl<'a> TypeContext<'a> for Context { ( SerializableVersionedBank::from(fields), SerializableAccountsDb::<'a, Self> { - accounts_db: &*serializable_bank.bank.rc.accounts.accounts_db, + accounts_db: &serializable_bank.bank.rc.accounts.accounts_db, slot: serializable_bank.bank.rc.slot, account_storage_entries: serializable_bank.snapshot_storages, phantom: std::marker::PhantomData::default(), diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index 1de6ee2a5d..5834a23f96 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -155,7 +155,7 @@ fn test_accounts_serialize_style(serde_style: SerdeStyle) { accountsdb_to_stream( serde_style, &mut writer, - &*accounts.accounts_db, + &accounts.accounts_db, 0, &accounts.accounts_db.get_snapshot_storages(0, None, None).0, ) diff --git a/runtime/src/snapshot_minimizer.rs b/runtime/src/snapshot_minimizer.rs index 69e7a99e8e..94a82e1d48 100644 --- a/runtime/src/snapshot_minimizer.rs +++ b/runtime/src/snapshot_minimizer.rs @@ -543,7 +543,7 @@ mod tests { .accounts .iter() .filter_map(|(pubkey, account)| { - stake::program::check_id(account.owner()).then(|| *pubkey) + stake::program::check_id(account.owner()).then_some(*pubkey) }) .collect(); expected_stake_accounts.push(bootstrap_validator_pubkey); diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 19e9d02f68..6018db95d3 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -1181,7 +1181,7 @@ fn check_are_snapshots_compatible( let incremental_snapshot_archive_info = incremental_snapshot_archive_info.unwrap(); (full_snapshot_archive_info.slot() == incremental_snapshot_archive_info.base_slot()) - .then(|| ()) + .then_some(()) .ok_or_else(|| { SnapshotError::MismatchedBaseSlot( full_snapshot_archive_info.slot(), diff --git a/runtime/src/storable_accounts.rs b/runtime/src/storable_accounts.rs index 8d79c0f78c..bfa35cf71c 100644 --- a/runtime/src/storable_accounts.rs +++ b/runtime/src/storable_accounts.rs @@ -143,7 +143,7 @@ pub mod tests { slot, &vec![(&pk, &account, slot), (&pk, &account, slot)][..], ); - assert!(!(&test3).contains_multiple_slots()); + assert!(!test3.contains_multiple_slots()); let test3 = ( slot, &vec![(&pk, &account, slot), (&pk, &account, slot + 1)][..], diff --git a/runtime/src/system_instruction_processor.rs b/runtime/src/system_instruction_processor.rs index 67f1f93114..3b738df1d8 100644 --- a/runtime/src/system_instruction_processor.rs +++ b/runtime/src/system_instruction_processor.rs @@ -1626,7 +1626,7 @@ mod tests { .unwrap(); // super fun time; callback chooses to .clean_accounts(None) or not - callback(&*bank); + callback(&bank); // create a normal account at the same pubkey as the zero-lamports account let lamports = genesis_config.rent.minimum_balance(len2); diff --git a/sdk/program/src/message/compiled_keys.rs b/sdk/program/src/message/compiled_keys.rs index d56c7aca2c..c689d08f39 100644 --- a/sdk/program/src/message/compiled_keys.rs +++ b/sdk/program/src/message/compiled_keys.rs @@ -80,20 +80,20 @@ impl CompiledKeys { .chain( key_meta_map .iter() - .filter_map(|(key, meta)| (meta.is_signer && meta.is_writable).then(|| *key)), + .filter_map(|(key, meta)| (meta.is_signer && meta.is_writable).then_some(*key)), ) .collect(); let readonly_signer_keys: Vec = key_meta_map .iter() - .filter_map(|(key, meta)| (meta.is_signer && !meta.is_writable).then(|| *key)) + .filter_map(|(key, meta)| (meta.is_signer && !meta.is_writable).then_some(*key)) .collect(); let writable_non_signer_keys: Vec = key_meta_map .iter() - .filter_map(|(key, meta)| (!meta.is_signer && meta.is_writable).then(|| *key)) + .filter_map(|(key, meta)| (!meta.is_signer && meta.is_writable).then_some(*key)) .collect(); let readonly_non_signer_keys: Vec = key_meta_map .iter() - .filter_map(|(key, meta)| (!meta.is_signer && !meta.is_writable).then(|| *key)) + .filter_map(|(key, meta)| (!meta.is_signer && !meta.is_writable).then_some(*key)) .collect(); let signers_len = writable_signer_keys @@ -160,7 +160,7 @@ impl CompiledKeys { for search_key in self .key_meta_map .iter() - .filter_map(|(key, meta)| key_meta_filter(meta).then(|| key)) + .filter_map(|(key, meta)| key_meta_filter(meta).then_some(key)) { for (key_index, key) in lookup_table_addresses.iter().enumerate() { if key == search_key { diff --git a/sdk/program/src/nonce/state/mod.rs b/sdk/program/src/nonce/state/mod.rs index a4a850b93c..d55bc9063a 100644 --- a/sdk/program/src/nonce/state/mod.rs +++ b/sdk/program/src/nonce/state/mod.rs @@ -46,7 +46,7 @@ impl Versions { Self::Current(state) => match **state { State::Uninitialized => None, State::Initialized(ref data) => { - (recent_blockhash == &data.blockhash()).then(|| data) + (recent_blockhash == &data.blockhash()).then_some(data) } }, } diff --git a/sdk/program/src/stake/tools.rs b/sdk/program/src/stake/tools.rs index 842a822b0e..e0447f49fc 100644 --- a/sdk/program/src/stake/tools.rs +++ b/sdk/program/src/stake/tools.rs @@ -28,7 +28,7 @@ fn get_minimum_delegation_return_data() -> Result { .ok_or(ProgramError::InvalidInstructionData) .and_then(|(program_id, return_data)| { (program_id == super::program::id()) - .then(|| return_data) + .then_some(return_data) .ok_or(ProgramError::IncorrectProgramId) }) .and_then(|return_data| { diff --git a/streamer/src/streamer.rs b/streamer/src/streamer.rs index 3492f60c89..1ef9b98930 100644 --- a/streamer/src/streamer.rs +++ b/streamer/src/streamer.rs @@ -307,7 +307,7 @@ fn recv_send( let packets = packet_batch.iter().filter_map(|pkt| { let addr = pkt.meta.socket_addr(); let data = pkt.data(..)?; - socket_addr_space.check(&addr).then(|| (data, addr)) + socket_addr_space.check(&addr).then_some((data, addr)) }); batch_send(sock, &packets.collect::>())?; Ok(()) diff --git a/validator/src/bootstrap.rs b/validator/src/bootstrap.rs index fec9f6d409..c5a4b65d4b 100644 --- a/validator/src/bootstrap.rs +++ b/validator/src/bootstrap.rs @@ -409,7 +409,7 @@ pub fn attempt_download_genesis_and_snapshot( .map_err(|err| format!("Failed to get RPC node slot: {}", err))?; info!("RPC node root slot: {}", rpc_client_slot); - if let Err(err) = download_snapshots( + download_snapshots( full_snapshot_archives_dir, incremental_snapshot_archives_dir, validator_config, @@ -422,9 +422,7 @@ pub fn attempt_download_genesis_and_snapshot( download_abort_count, snapshot_hash, rpc_contact_info, - ) { - return Err(err); - }; + )?; if let Some(url) = bootstrap_config.check_vote_account.as_ref() { let rpc_client = RpcClient::new(url); diff --git a/zk-token-sdk/src/instruction/close_account.rs b/zk-token-sdk/src/instruction/close_account.rs index 4525f87901..b6702e3051 100644 --- a/zk-token-sdk/src/instruction/close_account.rs +++ b/zk-token-sdk/src/instruction/close_account.rs @@ -41,7 +41,7 @@ impl CloseAccountData { keypair: &ElGamalKeypair, ciphertext: &ElGamalCiphertext, ) -> Result { - let pod_pubkey = pod::ElGamalPubkey((&keypair.public).to_bytes()); + let pod_pubkey = pod::ElGamalPubkey(keypair.public.to_bytes()); let pod_ciphertext = pod::ElGamalCiphertext(ciphertext.to_bytes()); let mut transcript = CloseAccountProof::transcript_new(&pod_pubkey, &pod_ciphertext); diff --git a/zk-token-sdk/src/instruction/withdraw.rs b/zk-token-sdk/src/instruction/withdraw.rs index 9aa606e8ca..64f540a591 100644 --- a/zk-token-sdk/src/instruction/withdraw.rs +++ b/zk-token-sdk/src/instruction/withdraw.rs @@ -62,7 +62,7 @@ impl WithdrawData { // current source balance let final_ciphertext = current_ciphertext - &ElGamal::encode(amount); - let pod_pubkey = pod::ElGamalPubkey((&keypair.public).to_bytes()); + let pod_pubkey = pod::ElGamalPubkey(keypair.public.to_bytes()); let pod_final_ciphertext: pod::ElGamalCiphertext = final_ciphertext.into(); let mut transcript = WithdrawProof::transcript_new(&pod_pubkey, &pod_final_ciphertext); let proof = WithdrawProof::new(keypair, final_balance, &final_ciphertext, &mut transcript);