From 24fe473b466fa24e267b042ba2544580479c099c Mon Sep 17 00:00:00 2001 From: Brooks Date: Fri, 22 Mar 2024 13:48:46 -0400 Subject: [PATCH] clippy: Automated fixes for Rust 1.77.0 (#390) --- accounts-db/src/accounts_db.rs | 2 +- accounts-db/src/accounts_hash.rs | 2 +- accounts-db/src/accounts_index.rs | 2 +- accounts-db/src/accounts_index/in_mem_accounts_index.rs | 4 ++-- core/src/repair/repair_service.rs | 2 +- entry/src/entry.rs | 4 ++-- program-test/src/lib.rs | 2 +- rpc-client-nonce-utils/src/nonblocking/mod.rs | 2 +- rpc/src/rpc_subscriptions.rs | 2 +- sdk/program/src/message/account_keys.rs | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 34bcdedd2..d900f0a2a 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -12102,7 +12102,7 @@ pub mod tests { db.print_accounts_stats("pre"); let slots: HashSet = vec![1].into_iter().collect(); - let purge_keys = vec![(key1, slots)]; + let purge_keys = [(key1, slots)]; let _ = db.purge_keys_exact(purge_keys.iter()); let account2 = AccountSharedData::new(3, 0, &key); diff --git a/accounts-db/src/accounts_hash.rs b/accounts-db/src/accounts_hash.rs index cb75369d5..06ce9b49f 100644 --- a/accounts-db/src/accounts_hash.rs +++ b/accounts-db/src/accounts_hash.rs @@ -1609,7 +1609,7 @@ mod tests { #[test] fn test_accountsdb_de_dup_accounts_zero_chunks() { - let vec = vec![vec![CalculateHashIntermediate { + let vec = [vec![CalculateHashIntermediate { lamports: 1, hash: AccountHash(Hash::default()), pubkey: Pubkey::default(), diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index bd57e0803..04426251f 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -120,7 +120,7 @@ impl ScanConfig { /// use existing 'abort' if available, otherwise allocate one pub fn recreate_with_abort(&self) -> Self { ScanConfig { - abort: Some(self.abort.as_ref().map(Arc::clone).unwrap_or_default()), + abort: Some(self.abort.clone().unwrap_or_default()), collect_all_unsorted: self.collect_all_unsorted, } } diff --git a/accounts-db/src/accounts_index/in_mem_accounts_index.rs b/accounts-db/src/accounts_index/in_mem_accounts_index.rs index 3df05ee5a..f3318470e 100644 --- a/accounts-db/src/accounts_index/in_mem_accounts_index.rs +++ b/accounts-db/src/accounts_index/in_mem_accounts_index.rs @@ -175,7 +175,7 @@ impl + Into> InMemAccountsIndex + Into> InMemAccountsIndex RT { // SAFETY: Since we're passing the entry Arc clone to `callback`, we must // also add the entry to the in-mem cache. - self.get_internal(pubkey, |entry| (true, callback(entry.map(Arc::clone)))) + self.get_internal(pubkey, |entry| (true, callback(entry.cloned()))) } /// lookup 'pubkey' in index (in_mem or disk). diff --git a/core/src/repair/repair_service.rs b/core/src/repair/repair_service.rs index 9431d7a25..9a293f6a8 100644 --- a/core/src/repair/repair_service.rs +++ b/core/src/repair/repair_service.rs @@ -872,7 +872,7 @@ impl RepairService { ServeRepair::repair_proto_to_bytes(&request_proto, &identity_keypair).unwrap(); // Prepare packet batch to send - let reqs = vec![(packet_buf, address)]; + let reqs = [(packet_buf, address)]; // Send packet batch match batch_send(repair_socket, &reqs[..]) { diff --git a/entry/src/entry.rs b/entry/src/entry.rs index af3fdca95..46aad401d 100644 --- a/entry/src/entry.rs +++ b/entry/src/entry.rs @@ -1104,7 +1104,7 @@ mod tests { let tx1 = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, zero); // Verify entry with 2 transactions - let mut e0 = vec![Entry::new(&zero, 0, vec![tx0, tx1])]; + let mut e0 = [Entry::new(&zero, 0, vec![tx0, tx1])]; assert!(e0.verify(&zero)); // Clear signature of the first transaction, see that it does not verify @@ -1124,7 +1124,7 @@ mod tests { assert!(!e0.verify(&zero)); // Pass an entry with no transactions - let e0 = vec![Entry::new(&zero, 0, vec![])]; + let e0 = [Entry::new(&zero, 0, vec![])]; assert!(e0.verify(&zero)); } diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index f4fba5761..8b786aa79 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -87,7 +87,7 @@ pub enum ProgramTestError { } thread_local! { - static INVOKE_CONTEXT: RefCell> = RefCell::new(None); + static INVOKE_CONTEXT: RefCell> = const { RefCell::new(None) }; } fn set_invoke_context(new: &mut InvokeContext) { INVOKE_CONTEXT diff --git a/rpc-client-nonce-utils/src/nonblocking/mod.rs b/rpc-client-nonce-utils/src/nonblocking/mod.rs index fceeacf6f..19ec9b619 100644 --- a/rpc-client-nonce-utils/src/nonblocking/mod.rs +++ b/rpc-client-nonce-utils/src/nonblocking/mod.rs @@ -228,7 +228,7 @@ pub fn data_from_account>( account: &T, ) -> Result { account_identity_ok(account)?; - state_from_account(account).and_then(|ref s| data_from_state(s).map(|d| d.clone())) + state_from_account(account).and_then(|ref s| data_from_state(s).cloned()) } /// Get the nonce data from its [`State`] value. diff --git a/rpc/src/rpc_subscriptions.rs b/rpc/src/rpc_subscriptions.rs index 39d746c48..f3594c67c 100644 --- a/rpc/src/rpc_subscriptions.rs +++ b/rpc/src/rpc_subscriptions.rs @@ -266,7 +266,7 @@ struct RpcNotifier { } thread_local! { - static RPC_NOTIFIER_BUF: RefCell> = RefCell::new(Vec::new()); + static RPC_NOTIFIER_BUF: RefCell> = const { RefCell::new(Vec::new()) }; } #[derive(Debug, Serialize)] diff --git a/sdk/program/src/message/account_keys.rs b/sdk/program/src/message/account_keys.rs index f0ab7deee..6f80c3c68 100644 --- a/sdk/program/src/message/account_keys.rs +++ b/sdk/program/src/message/account_keys.rs @@ -171,7 +171,7 @@ mod tests { }; let account_keys = AccountKeys::new(&static_keys, Some(&dynamic_keys)); - let expected_segments = vec![ + let expected_segments = [ vec![keys[0], keys[1], keys[2]], vec![keys[3], keys[4]], vec![keys[5]],