فهرست منبع

chore: fix rust_2024_incompatible_pat warnings (#8991)

* chore(unknown): fix rust_2024_incompatible_pat warnings

* Change account_locks to use as_ref()

* Add rust_2024_incompatible_pat to deny list of workspaces

* Use .as_ref() instead of &mut Some(..) in ReplayStage

* Use **value instead of &(&value..) pattern
Kamil Skalski 1 هفته پیش
والد
کامیت
926b206f77

+ 1 - 0
Cargo.toml

@@ -174,6 +174,7 @@ impl_trait_overcaptures = "deny"
 missing_unsafe_on_extern = "deny"
 never_type_fallback_flowing_into_unsafe = "deny"
 rust_2024_guarded_string_incompatible_syntax = "deny"
+rust_2024_incompatible_pat = "deny"
 rust_2024_prelude_collisions = "deny"
 static_mut_refs = "deny"
 

+ 1 - 1
accounts-db/src/account_locks.rs

@@ -43,7 +43,7 @@ impl AccountLocks {
         >,
     ) -> Vec<TransactionResult<()>> {
         validated_batch_keys.iter_mut().for_each(|validated_keys| {
-            if let Ok(ref keys) = validated_keys {
+            if let Ok(keys) = validated_keys.as_ref() {
                 if let Err(e) = self.can_lock_accounts(keys.clone()) {
                     *validated_keys = Err(e);
                 }

+ 8 - 8
cli/src/cli.rs

@@ -1190,7 +1190,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             sign_only,
             dump_transaction_message,
             blockhash_query,
-            ref nonce_account,
+            nonce_account,
             nonce_authority,
             memo,
             fee_payer,
@@ -1355,7 +1355,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
         } => process_show_stake_history(&rpc_client, config, *use_lamports_unit, *limit_results),
         CliCommand::StakeAuthorize {
             stake_account_pubkey,
-            ref new_authorizations,
+            new_authorizations,
             sign_only,
             dump_transaction_message,
             blockhash_query,
@@ -1420,7 +1420,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             sign_only,
             dump_transaction_message,
             blockhash_query,
-            ref nonce_account,
+            nonce_account,
             nonce_authority,
             memo,
             seed,
@@ -1482,7 +1482,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             sign_only,
             dump_transaction_message,
             blockhash_query,
-            ref nonce_account,
+            nonce_account,
             nonce_authority,
             memo,
             fee_payer,
@@ -1528,7 +1528,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             sign_only,
             dump_transaction_message,
             blockhash_query,
-            ref nonce_account,
+            nonce_account,
             nonce_authority,
             memo,
             fee_payer,
@@ -1688,13 +1688,13 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
             dump_transaction_message,
             allow_unfunded_recipient,
             no_wait,
-            ref blockhash_query,
-            ref nonce_account,
+            blockhash_query,
+            nonce_account,
             nonce_authority,
             memo,
             fee_payer,
             derived_address_seed,
-            ref derived_address_program_id,
+            derived_address_program_id,
             compute_unit_price,
         } => process_transfer(
             &rpc_client,

+ 1 - 1
cli/src/inflation.rs

@@ -79,7 +79,7 @@ pub fn process_inflation_subcommand(
 ) -> ProcessResult {
     match inflation_subcommand {
         InflationCliCommand::Show => process_show(rpc_client, config),
-        InflationCliCommand::Rewards(ref addresses, rewards_epoch) => {
+        InflationCliCommand::Rewards(addresses, rewards_epoch) => {
             process_rewards(rpc_client, config, addresses, *rewards_epoch)
         }
     }

+ 8 - 8
core/src/banking_stage/consume_worker.rs

@@ -2261,8 +2261,8 @@ mod tests {
             mint_keypair,
             genesis_config,
             bank,
-            ref mut record_receiver,
-            ref mut shared_leader_state,
+            record_receiver,
+            shared_leader_state,
             consume_sender,
             consumed_receiver,
             ..
@@ -2315,8 +2315,8 @@ mod tests {
             mint_keypair,
             genesis_config,
             bank,
-            ref mut record_receiver,
-            ref mut shared_leader_state,
+            record_receiver,
+            shared_leader_state,
             consume_sender,
             consumed_receiver,
             ..
@@ -2380,8 +2380,8 @@ mod tests {
             mint_keypair,
             genesis_config,
             bank,
-            ref mut record_receiver,
-            ref mut shared_leader_state,
+            record_receiver,
+            shared_leader_state,
             consume_sender,
             consumed_receiver,
             ..
@@ -2459,8 +2459,8 @@ mod tests {
             mint_keypair,
             genesis_config,
             bank,
-            ref mut record_receiver,
-            ref mut shared_leader_state,
+            record_receiver,
+            shared_leader_state,
             consume_sender,
             consumed_receiver,
             ..

+ 1 - 1
core/src/cluster_info_vote_listener.rs

@@ -704,7 +704,7 @@ impl ClusterInfoVoteListener {
         gossip_vote_slot_confirming_time.stop();
         let gossip_vote_slot_confirming_time_us = gossip_vote_slot_confirming_time.as_us();
 
-        if let Some(ref mut vote_processing_time) = vote_processing_time {
+        if let Some(vote_processing_time) = vote_processing_time {
             vote_processing_time.update(
                 gossip_vote_txn_processing_time_us,
                 gossip_vote_slot_confirming_time_us,

+ 4 - 4
core/src/replay_stage.rs

@@ -2053,7 +2053,7 @@ impl ReplayStage {
         current_leader: &mut Option<Pubkey>,
         new_leader: &Pubkey,
     ) {
-        if let Some(ref current_leader) = current_leader {
+        if let Some(current_leader) = current_leader.as_ref() {
             if current_leader != new_leader {
                 let msg = if current_leader == my_pubkey {
                     ". I am no longer the leader"
@@ -7236,7 +7236,7 @@ pub(crate) mod tests {
             ..
         } = replay_blockstore_components(Some(forks), 1, None);
 
-        let VoteSimulator {
+        let &mut VoteSimulator {
             ref mut progress,
             ref bank_forks,
             ..
@@ -7330,7 +7330,7 @@ pub(crate) mod tests {
             ..
         } = replay_components;
 
-        let VoteSimulator {
+        let &mut VoteSimulator {
             ref mut progress,
             ref bank_forks,
             ref mut tbft_structs,
@@ -8824,7 +8824,7 @@ pub(crate) mod tests {
             ..
         } = replay_blockstore_components(Some(forks), 1, None);
 
-        let VoteSimulator {
+        let &mut VoteSimulator {
             ref mut progress,
             ref bank_forks,
             ..

+ 1 - 1
cost-model/src/cost_tracker.rs

@@ -291,7 +291,7 @@ impl CostTracker {
     fn find_costliest_account(&self) -> (Pubkey, u64) {
         self.cost_by_writable_accounts
             .iter()
-            .max_by_key(|(_, &cost)| cost)
+            .max_by_key(|(_, cost)| **cost)
             .map(|(&pubkey, &cost)| (pubkey, cost))
             .unwrap_or_default()
     }

+ 1 - 0
dev-bins/Cargo.toml

@@ -30,6 +30,7 @@ impl_trait_overcaptures = "deny"
 missing_unsafe_on_extern = "deny"
 never_type_fallback_flowing_into_unsafe = "deny"
 rust_2024_guarded_string_incompatible_syntax = "deny"
+rust_2024_incompatible_pat = "deny"
 rust_2024_prelude_collisions = "deny"
 static_mut_refs = "deny"
 

+ 2 - 2
notifier/src/lib.rs

@@ -212,8 +212,8 @@ impl Notifier {
                         NotificationType::Resolve { incident: _ } => String::from("resolve"),
                     };
                     let dedup_key = match notification_type {
-                        NotificationType::Trigger { ref incident } => incident.clone().to_string(),
-                        NotificationType::Resolve { ref incident } => incident.clone().to_string(),
+                        NotificationType::Trigger { incident } => incident.clone().to_string(),
+                        NotificationType::Resolve { incident } => incident.clone().to_string(),
                     };
 
                     let data = json!({"payload":{"summary":msg,"source":"agave-watchtower","severity":"critical"},"routing_key":routing_key,"event_action":event_action,"dedup_key":dedup_key});

+ 1 - 1
programs/system/src/system_instruction.rs

@@ -110,7 +110,7 @@ pub(crate) fn withdraw_nonce_account(
             }
             *from.get_key()
         }
-        State::Initialized(ref data) => {
+        State::Initialized(data) => {
             if lamports == from.get_lamports() {
                 let durable_nonce =
                     DurableNonce::from_blockhash(&invoke_context.environment_config.blockhash);

+ 2 - 2
rpc-client-nonce-utils/src/blockhash_query.rs

@@ -29,7 +29,7 @@ impl Source {
                 let (blockhash, _) = rpc_client.get_latest_blockhash_with_commitment(commitment)?;
                 Ok(blockhash)
             }
-            Self::NonceAccount(ref pubkey) => {
+            Self::NonceAccount(pubkey) => {
                 let data = crate::get_account_with_commitment(rpc_client, pubkey, commitment)
                     .and_then(|ref a| crate::data_from_account(a))?;
                 Ok(data.blockhash())
@@ -45,7 +45,7 @@ impl Source {
     ) -> Result<bool, Box<dyn std::error::Error>> {
         Ok(match self {
             Self::Cluster => rpc_client.is_blockhash_valid(blockhash, commitment)?,
-            Self::NonceAccount(ref pubkey) => {
+            Self::NonceAccount(pubkey) => {
                 let _ = crate::get_account_with_commitment(rpc_client, pubkey, commitment)
                     .and_then(|ref a| crate::data_from_account(a))?;
                 true

+ 2 - 2
rpc-client-nonce-utils/src/nonblocking/blockhash_query.rs

@@ -31,7 +31,7 @@ impl Source {
                     .await?;
                 Ok(blockhash)
             }
-            Self::NonceAccount(ref pubkey) => {
+            Self::NonceAccount(pubkey) => {
                 let data = nonblocking::get_account_with_commitment(rpc_client, pubkey, commitment)
                     .await
                     .and_then(|ref a| nonblocking::data_from_account(a))?;
@@ -48,7 +48,7 @@ impl Source {
     ) -> Result<bool, Box<dyn std::error::Error>> {
         Ok(match self {
             Self::Cluster => rpc_client.is_blockhash_valid(blockhash, commitment).await?,
-            Self::NonceAccount(ref pubkey) => {
+            Self::NonceAccount(pubkey) => {
                 let _ = nonblocking::get_account_with_commitment(rpc_client, pubkey, commitment)
                     .await
                     .and_then(|ref a| nonblocking::data_from_account(a))?;

+ 1 - 1
runtime/src/bank/partitioned_epoch_rewards/mod.rs

@@ -1008,7 +1008,7 @@ mod tests {
         let vote_account = genesis_config
             .accounts
             .iter()
-            .find(|(&address, _)| address == vote_key)
+            .find(|(address, _)| **address == vote_key)
             .map(|(_, account)| account)
             .unwrap()
             .clone();

+ 4 - 4
runtime/src/bank/tests.rs

@@ -4526,7 +4526,7 @@ fn test_nonce_fee_calculator_updates() {
         .and_then(|acc| {
             let nonce_versions = StateMut::<nonce::versions::Versions>::state(&acc);
             match nonce_versions.ok()?.state() {
-                nonce::state::State::Initialized(ref data) => {
+                nonce::state::State::Initialized(data) => {
                     Some((data.blockhash(), data.fee_calculator))
                 }
                 _ => None,
@@ -4558,7 +4558,7 @@ fn test_nonce_fee_calculator_updates() {
         .and_then(|acc| {
             let nonce_versions = StateMut::<nonce::versions::Versions>::state(&acc);
             match nonce_versions.ok()?.state() {
-                nonce::state::State::Initialized(ref data) => {
+                nonce::state::State::Initialized(data) => {
                     Some((data.blockhash(), data.fee_calculator))
                 }
                 _ => None,
@@ -4590,7 +4590,7 @@ fn test_nonce_fee_calculator_updates_tx_wide_cap() {
         .and_then(|acc| {
             let nonce_versions = StateMut::<nonce::versions::Versions>::state(&acc);
             match nonce_versions.ok()?.state() {
-                nonce::state::State::Initialized(ref data) => {
+                nonce::state::State::Initialized(data) => {
                     Some((data.blockhash(), data.fee_calculator))
                 }
                 _ => None,
@@ -4622,7 +4622,7 @@ fn test_nonce_fee_calculator_updates_tx_wide_cap() {
         .and_then(|acc| {
             let nonce_versions = StateMut::<nonce::versions::Versions>::state(&acc);
             match nonce_versions.ok()?.state() {
-                nonce::state::State::Initialized(ref data) => {
+                nonce::state::State::Initialized(data) => {
                     Some((data.blockhash(), data.fee_calculator))
                 }
                 _ => None,

+ 1 - 1
syscalls/src/sysvar.rs

@@ -241,7 +241,7 @@ declare_builtin_function!(
         let cache = invoke_context.get_sysvar_cache();
 
         // "`2` if the sysvar data is not present in the Sysvar Cache."
-        let Some(ref sysvar_buf) = cache.sysvar_id_to_buffer(sysvar_id) else { return Ok(SYSVAR_NOT_FOUND) };
+        let Some(sysvar_buf) = cache.sysvar_id_to_buffer(sysvar_id) else { return Ok(SYSVAR_NOT_FOUND) };
 
         // "`1` if `offset + length` is greater than the length of the sysvar data."
         if let Some(sysvar_slice) = sysvar_buf.get(offset as usize..offset_length as usize) {

+ 1 - 1
unified-scheduler-logic/src/lib.rs

@@ -785,7 +785,7 @@ impl UsageQueueInner {
         match self {
             Self::Fifo { current_usage, .. } => {
                 match current_usage {
-                    Some(FifoUsage::Readonly(ref mut count)) => match requested_usage {
+                    Some(FifoUsage::Readonly(count)) => match requested_usage {
                         RequestedUsage::Readonly => {
                             if count.is_one() {
                                 is_newly_lockable = true;

+ 1 - 1
validator/src/bootstrap.rs

@@ -340,7 +340,7 @@ pub fn fail_rpc_node(
     blacklisted_rpc_nodes: &mut HashSet<Pubkey, RandomState>,
 ) {
     warn!("{err}");
-    if let Some(ref known_validators) = known_validators {
+    if let Some(known_validators) = known_validators {
         if known_validators.contains(rpc_id) {
             return;
         }