diff --git a/packages/canlog/src/lib.rs b/packages/canlog/src/lib.rs index 5e29b4012e2f..6764f92b2460 100644 --- a/packages/canlog/src/lib.rs +++ b/packages/canlog/src/lib.rs @@ -204,11 +204,11 @@ where } fn sort_asc(&mut self) { - self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp)); + self.entries.sort_by_key(|a| a.timestamp); } fn sort_desc(&mut self) { - self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp)); + self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp)); } } diff --git a/rs/bitcoin/adapter/src/blockchainstate.rs b/rs/bitcoin/adapter/src/blockchainstate.rs index 32faa16189a1..5c1bdb2cc900 100644 --- a/rs/bitcoin/adapter/src/blockchainstate.rs +++ b/rs/bitcoin/adapter/src/blockchainstate.rs @@ -586,7 +586,7 @@ mod test { ); let mut tips = crate::header_cache::test::get_tips(&state.header_cache); - tips.sort_by(|x, y| y.work.cmp(&x.work)); + tips.sort_by_key(|y| std::cmp::Reverse(y.work)); assert_eq!(tips.len(), 2); assert_eq!(tips[0].header.block_hash(), *last_fork_hash); assert_eq!(tips[1].header.block_hash(), *last_chain_hash); diff --git a/rs/bitcoin/adapter/src/rpc_server.rs b/rs/bitcoin/adapter/src/rpc_server.rs index 024cbce25d5f..ad63325f6a50 100644 --- a/rs/bitcoin/adapter/src/rpc_server.rs +++ b/rs/bitcoin/adapter/src/rpc_server.rs @@ -31,6 +31,7 @@ struct BtcServiceImpl { impl TryFrom for GetSuccessorsRequest { type Error = Status; + #[allow(clippy::result_large_err)] fn try_from(request: BtcServiceGetSuccessorsRequest) -> Result { let anchor = BlockHash::from_slice(request.anchor.as_slice()) .map_err(|_| Status::unknown("Failed to parse anchor hash!"))?; diff --git a/rs/bitcoin/ckbtc/minter/src/lib.rs b/rs/bitcoin/ckbtc/minter/src/lib.rs index 38e53f28a446..60556c141184 100644 --- a/rs/bitcoin/ckbtc/minter/src/lib.rs +++ b/rs/bitcoin/ckbtc/minter/src/lib.rs @@ -305,7 +305,7 @@ fn reimburse_canceled_requests( requests.len(), state.retrieve_btc_min_amount ); - for (request, fee) in requests.into_iter().zip(fees.into_iter()) { + for (request, fee) in requests.into_iter().zip(fees) { if let Some(account) = request.reimbursement_account { let amount = request.amount.saturating_sub(fee); if amount > 0 { diff --git a/rs/bitcoin/ckbtc/minter/tests/tests.rs b/rs/bitcoin/ckbtc/minter/tests/tests.rs index df96e9b07632..fc1cb9b37655 100644 --- a/rs/bitcoin/ckbtc/minter/tests/tests.rs +++ b/rs/bitcoin/ckbtc/minter/tests/tests.rs @@ -1503,7 +1503,7 @@ impl CkBtcSetup { pub fn print_minter_canister_logs(&self) { let log = self.env.canister_log(self.minter_id); let mut records = log.records().iter().collect::>(); - records.sort_by(|a, b| a.idx.cmp(&b.idx)); + records.sort_by_key(|a| a.idx); for entry in records { println!( "[{}] {}: {}", diff --git a/rs/consensus/certification/src/certifier.rs b/rs/consensus/certification/src/certifier.rs index cb71cf210c50..a02af098f609 100644 --- a/rs/consensus/certification/src/certifier.rs +++ b/rs/consensus/certification/src/certifier.rs @@ -1044,7 +1044,7 @@ mod tests { .collect(); // sort by heights - certs.sort_by(|s1, s2| s1.height.cmp(&s2.height)); + certs.sort_by_key(|s| s.height); assert_eq!(certs[0].height, Height::from(3)); assert_eq!(certs[1].height, Height::from(4)); diff --git a/rs/consensus/idkg/src/test_utils.rs b/rs/consensus/idkg/src/test_utils.rs index 074dc37fb47d..4dfaa69ee76e 100644 --- a/rs/consensus/idkg/src/test_utils.rs +++ b/rs/consensus/idkg/src/test_utils.rs @@ -765,8 +765,8 @@ pub(crate) fn get_dealings_and_support( ) -> (BTreeMap, Vec) { let dealings = env.nodes.create_and_verify_signed_dealings(params); let supports = dealings - .iter() - .flat_map(|(_, dealing)| { + .values() + .flat_map(|dealing| { env.nodes.filter_by_receivers(¶ms).map(|signer| { let c: Arc = signer.crypto(); let sig_share = c diff --git a/rs/crypto/internal/crypto_lib/threshold_sig/bls12_381/src/ni_dkg/fs_ni_dkg/nizk_chunking.rs b/rs/crypto/internal/crypto_lib/threshold_sig/bls12_381/src/ni_dkg/fs_ni_dkg/nizk_chunking.rs index 7a8b71c962d9..d457c0d6240b 100644 --- a/rs/crypto/internal/crypto_lib/threshold_sig/bls12_381/src/ni_dkg/fs_ni_dkg/nizk_chunking.rs +++ b/rs/crypto/internal/crypto_lib/threshold_sig/bls12_381/src/ni_dkg/fs_ni_dkg/nizk_chunking.rs @@ -295,9 +295,8 @@ pub fn prove_chunking( let xpowers = Scalar::xpowers(&second_challenge, NUM_ZK_REPETITIONS); let mut z_r = Vec::with_capacity(first_challenge.len()); - let mut delta_idx = 1; - for e_i in first_challenge.iter() { + for (delta_idx, e_i) in (1_usize..).zip(first_challenge.iter()) { let mut xpow_e_ij = Vec::with_capacity(e_i.len()); for j in 0..e_i.len() { xpow_e_ij.push(Scalar::muln_usize_vartime(&xpowers, &e_i[j])); @@ -306,8 +305,6 @@ pub fn prove_chunking( let z_rk = Scalar::muln_vartime(&witness.scalars_r, &xpow_e_ij) + &delta[delta_idx]; z_r.push(z_rk); - - delta_idx += 1; } let z_beta = Scalar::muln_vartime(&beta, &xpowers) + &delta[0]; diff --git a/rs/crypto/tests/canister_threshold_idkg.rs b/rs/crypto/tests/canister_threshold_idkg.rs index 9562485351e3..056805ad1f00 100644 --- a/rs/crypto/tests/canister_threshold_idkg.rs +++ b/rs/crypto/tests/canister_threshold_idkg.rs @@ -3665,7 +3665,7 @@ mod reshare_key_transcript { let nodes_involved_in_resharing: Nodes = source_subnet_nodes .into_filtered_by_receivers(&source_receivers) - .chain(target_subnet_nodes.into_iter()) + .chain(target_subnet_nodes) .collect(); let initial_dealings = { let signed_dealings = nodes_involved_in_resharing @@ -3751,7 +3751,7 @@ mod reshare_key_transcript { let nodes_involved_in_resharing: Nodes = source_subnet_nodes .into_filtered_by_receivers(&source_receivers) - .chain(target_subnet_nodes.into_iter()) + .chain(target_subnet_nodes) .collect(); let reshared_key_transcript = nodes_involved_in_resharing .run_idkg_and_create_and_verify_transcript(&reshare_params, rng); @@ -3807,7 +3807,7 @@ mod reshare_key_transcript { let nodes_involved_in_resharing: Nodes = source_subnet_nodes .into_filtered_by_receivers(&source_receivers) - .chain(target_subnet_nodes.into_iter()) + .chain(target_subnet_nodes) .collect(); let reshared_key_transcript = nodes_involved_in_resharing .run_idkg_and_create_and_verify_transcript(&reshare_params, rng); diff --git a/rs/ethereum/cketh/minter/src/logs.rs b/rs/ethereum/cketh/minter/src/logs.rs index 9f27ab635f29..9547073533d7 100644 --- a/rs/ethereum/cketh/minter/src/logs.rs +++ b/rs/ethereum/cketh/minter/src/logs.rs @@ -135,11 +135,11 @@ impl Log { } pub fn sort_asc(&mut self) { - self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp)); + self.entries.sort_by_key(|a| a.timestamp); } pub fn sort_desc(&mut self) { - self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp)); + self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp)); } } diff --git a/rs/ethereum/cketh/test_utils/src/lib.rs b/rs/ethereum/cketh/test_utils/src/lib.rs index 0639bd36013c..4050a31dd8db 100644 --- a/rs/ethereum/cketh/test_utils/src/lib.rs +++ b/rs/ethereum/cketh/test_utils/src/lib.rs @@ -701,7 +701,7 @@ impl CkEthSetup { let log = self.env.canister_log(self.minter_id); let mut records = log.records().iter().collect::>(); - records.sort_by(|a, b| a.idx.cmp(&b.idx)); + records.sort_by_key(|a| a.idx); records .into_iter() .map(|log| CanisterLog { diff --git a/rs/ethereum/ledger-suite-orchestrator/src/logs/mod.rs b/rs/ethereum/ledger-suite-orchestrator/src/logs/mod.rs index a8c47700ee97..c8f43b594ef1 100644 --- a/rs/ethereum/ledger-suite-orchestrator/src/logs/mod.rs +++ b/rs/ethereum/ledger-suite-orchestrator/src/logs/mod.rs @@ -131,10 +131,10 @@ impl Log { } pub fn sort_asc(&mut self) { - self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp)); + self.entries.sort_by_key(|a| a.timestamp); } pub fn sort_desc(&mut self) { - self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp)); + self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp)); } } diff --git a/rs/execution_environment/src/scheduler/tests/scheduling.rs b/rs/execution_environment/src/scheduler/tests/scheduling.rs index 8666248a9825..168afd86e283 100644 --- a/rs/execution_environment/src/scheduler/tests/scheduling.rs +++ b/rs/execution_environment/src/scheduler/tests/scheduling.rs @@ -725,11 +725,9 @@ fn scheduler_can_deplete_induction_pool_given_enough_execution_rounds( available_messages, instructions_per_round / instructions_per_message, ); - let required_rounds = if minimum_executed_messages != 0 { - available_messages / minimum_executed_messages + 1 - } else { - 1 - }; + let required_rounds = available_messages + .checked_div(minimum_executed_messages) + .map_or(1, |v| v + 1); for _ in 0..required_rounds { test.execute_round(ExecutionRoundType::OrdinaryRound); } diff --git a/rs/https_outcalls/consensus/src/pool_manager.rs b/rs/https_outcalls/consensus/src/pool_manager.rs index cab8d0ed7701..c3467a961f54 100644 --- a/rs/https_outcalls/consensus/src/pool_manager.rs +++ b/rs/https_outcalls/consensus/src/pool_manager.rs @@ -2360,6 +2360,7 @@ pub mod test { // `make_new_requests` will try to dispatch contexts to the adapter shim. // Accept any number of `send` calls and treat them as no-ops. + #[allow(clippy::result_large_err)] shim_mock.expect_send().returning(|_| Ok(())); let mut sequence = Sequence::new(); diff --git a/rs/interfaces/mocks/src/crypto.rs b/rs/interfaces/mocks/src/crypto.rs index cab3425e4555..efb330083a22 100644 --- a/rs/interfaces/mocks/src/crypto.rs +++ b/rs/interfaces/mocks/src/crypto.rs @@ -17,6 +17,8 @@ //! `VetKdArgs<'a>` (`'_` is forbidden, named lifetimes cannot be declared, and //! elision does not work inside the macro). +#![allow(clippy::result_large_err)] + use ic_crypto_interfaces_sig_verification::BasicSigVerifierByPublicKey; use ic_interfaces::crypto::{ BasicSigVerifier, BasicSigner, CheckKeysWithRegistryError, CurrentNodePublicKeysError, diff --git a/rs/ledger_suite/icp/index/src/main.rs b/rs/ledger_suite/icp/index/src/main.rs index 77d596848b72..79d22cdf0db4 100644 --- a/rs/ledger_suite/icp/index/src/main.rs +++ b/rs/ledger_suite/icp/index/src/main.rs @@ -460,6 +460,7 @@ fn append_blocks(new_blocks: Vec) -> Result<(), String> { // the index of the next block that we // are going to append let mut block_index = with_blocks(|blocks| blocks.len()); + #[allow(clippy::explicit_counter_loop)] for block in new_blocks { // append the encoded block to the block log with_blocks(|blocks| { diff --git a/rs/ledger_suite/icp/index/tests/tests.rs b/rs/ledger_suite/icp/index/tests/tests.rs index 76eaa59a0a84..86d4e32c3e01 100644 --- a/rs/ledger_suite/icp/index/tests/tests.rs +++ b/rs/ledger_suite/icp/index/tests/tests.rs @@ -525,9 +525,8 @@ fn assert_ledger_index_parity_query_blocks_and_query_encoded_blocks( // - the `created_at_time` field of the unencoded block is set to the `timestamp` field // of the block // - all the other fields of the blocks match - for (ledger_block, unencoded_ledger_block) in ledger_blocks - .into_iter() - .zip(ledger_unencoded_blocks.into_iter()) + for (ledger_block, unencoded_ledger_block) in + ledger_blocks.into_iter().zip(ledger_unencoded_blocks) { if ledger_block != unencoded_ledger_block { if ledger_block.transaction.created_at_time.is_none() { diff --git a/rs/ledger_suite/icp/ledger/tests/tests.rs b/rs/ledger_suite/icp/ledger/tests/tests.rs index 081a93821f1d..d0d7f5e86724 100644 --- a/rs/ledger_suite/icp/ledger/tests/tests.rs +++ b/rs/ledger_suite/icp/ledger/tests/tests.rs @@ -611,7 +611,7 @@ fn assert_candid_block_equals_icp_ledger_block( icp_ledger_blocks: Vec, ) { assert_eq!(candid_blocks.len(), icp_ledger_blocks.len()); - for (cb, lb) in candid_blocks.into_iter().zip(icp_ledger_blocks.into_iter()) { + for (cb, lb) in candid_blocks.into_iter().zip(icp_ledger_blocks) { assert_eq!( cb.parent_hash.map(|x| x.to_vec()), lb.parent_hash.map(|x| x.as_slice().to_vec()) @@ -1209,9 +1209,8 @@ fn test_block_transformation() { assert_eq!(certificate_pre_upgrade, certificate_post_upgrade); //Go through all blocks and make sure the blocks fetched before the upgrade are the same as after the upgrade - for (block_pre_upgrade, block_post_upgrade) in resp_pre_upgrade - .into_iter() - .zip(resp_post_upgrade.into_iter()) + for (block_pre_upgrade, block_post_upgrade) in + resp_pre_upgrade.into_iter().zip(resp_post_upgrade) { assert_eq!(block_pre_upgrade, block_post_upgrade); assert_eq!( diff --git a/rs/ledger_suite/icrc1/archive/src/main.rs b/rs/ledger_suite/icrc1/archive/src/main.rs index bd95a0b3d7a0..e466303e3d89 100644 --- a/rs/ledger_suite/icrc1/archive/src/main.rs +++ b/rs/ledger_suite/icrc1/archive/src/main.rs @@ -372,6 +372,7 @@ fn icrc3_get_blocks(reqs: Vec) -> GetBlocksResult { } let length = length.min(max_length); let decoded_block_range = decode_block_range(start, length, decode_icrc1_block); + #[allow(clippy::explicit_counter_loop)] for block in decoded_block_range { blocks.push(BlockWithId { id: id.clone(), diff --git a/rs/ledger_suite/icrc1/index-ng/src/main.rs b/rs/ledger_suite/icrc1/index-ng/src/main.rs index 9790fcd365fc..0ab6e2124236 100644 --- a/rs/ledger_suite/icrc1/index-ng/src/main.rs +++ b/rs/ledger_suite/icrc1/index-ng/src/main.rs @@ -946,6 +946,7 @@ fn append_blocks(new_blocks: Vec) -> Result<(), SyncError> { // the index of the next block that we // are going to append let mut block_index = with_blocks(|blocks| blocks.len()); + #[allow(clippy::explicit_counter_loop)] for block in new_blocks { append_block(block_index, block)?; block_index += 1; diff --git a/rs/ledger_suite/icrc1/index-ng/tests/tests.rs b/rs/ledger_suite/icrc1/index-ng/tests/tests.rs index 4ca13966fd76..85ce809190ef 100644 --- a/rs/ledger_suite/icrc1/index-ng/tests/tests.rs +++ b/rs/ledger_suite/icrc1/index-ng/tests/tests.rs @@ -358,7 +358,7 @@ fn assert_ledger_index_parity(env: &StateMachine, ledger_id: CanisterId, index_i for (index, (ledger_block, index_block)) in ledger_blocks .blocks .into_iter() - .zip(index_blocks.blocks.into_iter()) + .zip(index_blocks.blocks) .enumerate() { // If the hash matches then they are the same block. diff --git a/rs/ledger_suite/icrc1/ledger/tests/tests.rs b/rs/ledger_suite/icrc1/ledger/tests/tests.rs index c14a109ade3b..0d73051d69cf 100644 --- a/rs/ledger_suite/icrc1/ledger/tests/tests.rs +++ b/rs/ledger_suite/icrc1/ledger/tests/tests.rs @@ -1232,7 +1232,7 @@ fn test_icrc3_get_blocks() { for (local_index, (actual_block, expected_block)) in actual_res .blocks .into_iter() - .zip(expected_res.blocks.into_iter()) + .zip(expected_res.blocks) .enumerate() { check_old_vs_icrc3_blocks( @@ -1285,7 +1285,7 @@ fn test_icrc3_get_blocks() { for (block_index, (actual_block, expected_block)) in actual_archived_blocks .blocks .into_iter() - .zip(expected_archived_blocks.blocks.into_iter()) + .zip(expected_archived_blocks.blocks) .enumerate() { check_old_vs_icrc3_blocks(block_index, expected_block.clone(), actual_block.clone()); diff --git a/rs/ledger_suite/tests/sm-tests/src/lib.rs b/rs/ledger_suite/tests/sm-tests/src/lib.rs index 8001cd03f077..5f6fd562642d 100644 --- a/rs/ledger_suite/tests/sm-tests/src/lib.rs +++ b/rs/ledger_suite/tests/sm-tests/src/lib.rs @@ -1615,7 +1615,7 @@ where let mut prev_hash = None; // Check that the hash chain is correct. - for block in archived_blocks.into_iter().chain(resp.blocks.into_iter()) { + for block in archived_blocks.into_iter().chain(resp.blocks) { assert_eq!( prev_hash, get_phash(&block).expect("cannot get the hash of the previous block") @@ -2069,7 +2069,7 @@ pub fn icrc1_test_block_transformation( for (block_pre_upgrade, block_post_upgrade) in resp_pre_upgrade .blocks .into_iter() - .zip(resp_post_upgrade.blocks.into_iter()) + .zip(resp_post_upgrade.blocks) { assert!( equivalent_values(&block_pre_upgrade, &block_post_upgrade), diff --git a/rs/monitoring/adapter_metrics/server/src/lib.rs b/rs/monitoring/adapter_metrics/server/src/lib.rs index 32f5a8ff7d36..efc8e9176e0f 100644 --- a/rs/monitoring/adapter_metrics/server/src/lib.rs +++ b/rs/monitoring/adapter_metrics/server/src/lib.rs @@ -28,6 +28,7 @@ impl Metrics { #[tonic::async_trait] impl AdapterMetricsService for Metrics { + #[allow(clippy::result_large_err)] async fn scrape( &self, _request: Request, diff --git a/rs/nervous_system/agent/src/sns/swap.rs b/rs/nervous_system/agent/src/sns/swap.rs index 54a022d1bffc..0aed874b4269 100644 --- a/rs/nervous_system/agent/src/sns/swap.rs +++ b/rs/nervous_system/agent/src/sns/swap.rs @@ -78,7 +78,7 @@ impl SwapCanister { if new_sns_neuron_recipes.sns_neuron_recipes.is_empty() { return Ok(sns_neuron_recipes); } else { - sns_neuron_recipes.extend(new_sns_neuron_recipes.sns_neuron_recipes.into_iter()) + sns_neuron_recipes.extend(new_sns_neuron_recipes.sns_neuron_recipes) } } Err(ListAllSnsNeuronRecipesError::TooManyRecipes( diff --git a/rs/nervous_system/integration_tests/tests/sns_lifecycle.rs b/rs/nervous_system/integration_tests/tests/sns_lifecycle.rs index cdd5a879e17a..9c14b40f8527 100644 --- a/rs/nervous_system/integration_tests/tests/sns_lifecycle.rs +++ b/rs/nervous_system/integration_tests/tests/sns_lifecycle.rs @@ -294,7 +294,7 @@ async fn test_sns_lifecycle( .await .unwrap(); - stream::iter(nns_neuron_controller_principal_ids.into_iter()) + stream::iter(nns_neuron_controller_principal_ids) .then(|controller_principal_id| { let pocket_ic = &pocket_ic; async move { @@ -1589,8 +1589,7 @@ async fn test_sns_lifecycle( permissions: &[sns_pb::NeuronPermission], ) -> Vec { let mut permissions = permissions.to_vec(); - permissions - .sort_by(|x, y| y.principal.unwrap().cmp(&x.principal.unwrap())); + permissions.sort_by_key(|y| std::cmp::Reverse(y.principal.unwrap())); permissions } let claimer_permissions = nervous_system_parameters diff --git a/rs/nns/cmc/src/main.rs b/rs/nns/cmc/src/main.rs index b9a5fcc4ead7..a41bc4d29f4d 100644 --- a/rs/nns/cmc/src/main.rs +++ b/rs/nns/cmc/src/main.rs @@ -964,15 +964,12 @@ fn compute_average_icp_xdr_rate_at_time( let size = filtered_rates.len() as u64; // If there are rates that meet the age requirement, compute the sum and compute // the average. - if size > 0 { - let sum: u64 = filtered_rates.into_iter().sum(); - Some(IcpXdrConversionRate { - timestamp_seconds: day * 86_400, // Start of the current day. - xdr_permyriad_per_icp: sum / size, // The average of the valid data points. + let sum: u64 = filtered_rates.into_iter().sum(); + sum.checked_div(size) + .map(|xdr_permyriad_per_icp| IcpXdrConversionRate { + timestamp_seconds: day * 86_400, // Start of the current day. + xdr_permyriad_per_icp, // The average of the valid data points. }) - } else { - None - } } #[update(hidden = true)] diff --git a/rs/nns/governance/src/governance.rs b/rs/nns/governance/src/governance.rs index ee6a6a6768b4..01a682ce04bf 100644 --- a/rs/nns/governance/src/governance.rs +++ b/rs/nns/governance/src/governance.rs @@ -4660,6 +4660,7 @@ impl Governance { )); } } + #[allow(clippy::collapsible_match)] Command::Follow(follow) => { if follow.followees.len() > MAX_FOLLOWEES_PER_TOPIC { return Err(GovernanceError::new_with_message( @@ -4955,6 +4956,7 @@ impl Governance { Self::validate_add_or_remove_data_centers_payload(&update.payload) .map_err(invalid_proposal_error)?; } + #[allow(clippy::collapsible_match)] ValidNnsFunction::SplitSubnet => { if !are_subnet_splitting_proposals_enabled() { return Err(invalid_proposal_error(String::from( diff --git a/rs/nns/governance/src/governance/benches.rs b/rs/nns/governance/src/governance/benches.rs index 7eac24a5af3b..d73de59a1f53 100644 --- a/rs/nns/governance/src/governance/benches.rs +++ b/rs/nns/governance/src/governance/benches.rs @@ -303,7 +303,7 @@ fn set_up_chain( let previous_neuron_indices = (neuron_index - num_half_followees - 1)..neuron_index; let followee_neuron_ids = previous_neuron_indices .map(|index| neuron_ids[index as usize]) - .chain(not_voting_neuron_ids.clone().into_iter()) + .chain(not_voting_neuron_ids.clone()) .collect::>(); let followees = hashmap! {topic.into() => Followees {followees: followee_neuron_ids}}; diff --git a/rs/nns/governance/tests/governance.rs b/rs/nns/governance/tests/governance.rs index ff835a80a7da..f45296020e55 100644 --- a/rs/nns/governance/tests/governance.rs +++ b/rs/nns/governance/tests/governance.rs @@ -10931,8 +10931,7 @@ async fn test_known_neurons() { }, ]; let mut sorted_response_known_neurons = gov.list_known_neurons().known_neurons; - sorted_response_known_neurons - .sort_by(|a, b| a.id.as_ref().unwrap().id.cmp(&b.id.as_ref().unwrap().id)); + sorted_response_known_neurons.sort_by_key(|a| a.id.as_ref().unwrap().id); assert_eq!(sorted_response_known_neurons, expected_known_neurons); // This proposal tries to name neuron 1 with the already existing name "Two", this should fail. @@ -10959,8 +10958,7 @@ async fn test_known_neurons() { // Check that the state is the same as before the last proposal. let mut sorted_response_known_neurons = gov.list_known_neurons().known_neurons; - sorted_response_known_neurons - .sort_by(|a, b| a.id.as_ref().unwrap().id.cmp(&b.id.as_ref().unwrap().id)); + sorted_response_known_neurons.sort_by_key(|a| a.id.as_ref().unwrap().id); assert_eq!(sorted_response_known_neurons, expected_known_neurons); // Update the name of neuron 2. diff --git a/rs/nns/integration_tests/src/node_provider_remuneration.rs b/rs/nns/integration_tests/src/node_provider_remuneration.rs index e89264b226c2..b9d772efab7f 100644 --- a/rs/nns/integration_tests/src/node_provider_remuneration.rs +++ b/rs/nns/integration_tests/src/node_provider_remuneration.rs @@ -586,8 +586,8 @@ fn test_automated_node_provider_remuneration() { // All success failure rate is 0 let node_metrics_daily: Vec = nodes .clone() - .into_iter() - .flat_map(|(_, node_ids)| { + .into_values() + .flat_map(|node_ids| { node_ids.into_iter().map(|node_id| NodeMetricsDailyRaw { node_id, num_blocks_failed: 0, @@ -841,8 +841,8 @@ fn test_automated_node_provider_remuneration() { // All success failure rate is 0 let node_metrics_daily: Vec = nodes .clone() - .into_iter() - .flat_map(|(_, node_ids)| { + .into_values() + .flat_map(|node_ids| { node_ids.into_iter().map(|node_id| NodeMetricsDailyRaw { node_id, num_blocks_failed: 0, @@ -957,8 +957,8 @@ fn test_automated_node_provider_remuneration() { // All success failure rate is 0 let node_metrics_daily: Vec = nodes .clone() - .into_iter() - .flat_map(|(_, node_ids)| { + .into_values() + .flat_map(|node_ids| { node_ids.into_iter().map(|node_id| NodeMetricsDailyRaw { node_id, num_blocks_failed: 0, diff --git a/rs/nns/test_utils/src/state_test_helpers.rs b/rs/nns/test_utils/src/state_test_helpers.rs index 6be20b740020..c92a8c2ae230 100644 --- a/rs/nns/test_utils/src/state_test_helpers.rs +++ b/rs/nns/test_utils/src/state_test_helpers.rs @@ -1810,9 +1810,7 @@ pub fn list_all_neurons_and_combine_responses( new_request.page_number = Some(page); let mut new_response = list_neurons(state_machine, sender, new_request); response.full_neurons.append(&mut new_response.full_neurons); - response - .neuron_infos - .extend(new_response.neuron_infos.into_iter()); + response.neuron_infos.extend(new_response.neuron_infos); } response diff --git a/rs/p2p/artifact_downloader/src/fetch_stripped_artifact/stripper.rs b/rs/p2p/artifact_downloader/src/fetch_stripped_artifact/stripper.rs index 6a64043e5a17..7b5a0330b8d7 100644 --- a/rs/p2p/artifact_downloader/src/fetch_stripped_artifact/stripper.rs +++ b/rs/p2p/artifact_downloader/src/fetch_stripped_artifact/stripper.rs @@ -92,8 +92,8 @@ impl Strippable for &Option { fn strip(self) -> Self::Output { let stripped_dealings = if let Some(idkg) = self { idkg.idkg_transcripts - .iter() - .flat_map(|(_id, transcript)| { + .values() + .flat_map(|transcript| { transcript.verified_dealings.iter().map( |(dealer_index, batch_signed_dealing)| { (*dealer_index, batch_signed_dealing.content.message_id()) diff --git a/rs/p2p/consensus_manager/tests/test.rs b/rs/p2p/consensus_manager/tests/test.rs index ec53f9f28614..72940c00f280 100644 --- a/rs/p2p/consensus_manager/tests/test.rs +++ b/rs/p2p/consensus_manager/tests/test.rs @@ -354,7 +354,7 @@ fn load_test( node_advert_map.insert(node, processor); } let (nodes, topology_watcher) = fully_connected_localhost_subnet(rt.handle(), log, id, nodes); - for ((node1, transport), (node2, cm)) in nodes.into_iter().zip(cms.into_iter()) { + for ((node1, transport), (node2, cm)) in nodes.into_iter().zip(cms) { assert!(node1 == node2); cm.start(transport, topology_watcher.clone()); } diff --git a/rs/p2p/state_sync_manager/tests/common.rs b/rs/p2p/state_sync_manager/tests/common.rs index 7fb91ce63e1f..61cdef31a200 100644 --- a/rs/p2p/state_sync_manager/tests/common.rs +++ b/rs/p2p/state_sync_manager/tests/common.rs @@ -121,14 +121,8 @@ impl State { let other_state = other.0.lock().unwrap(); other_state .chunks - .iter() - .filter_map(|(k, _)| { - if !this_state.chunks.contains_key(k) { - Some(k) - } else { - None - } - }) + .keys() + .filter(|k| !this_state.chunks.contains_key(k)) .cloned() .collect() } diff --git a/rs/query_stats/src/payload_builder.rs b/rs/query_stats/src/payload_builder.rs index f1abd4da13d0..72a9142d6f7a 100644 --- a/rs/query_stats/src/payload_builder.rs +++ b/rs/query_stats/src/payload_builder.rs @@ -959,7 +959,7 @@ mod tests { .stats .entry(canister_id) // NOTE: This assumes that there are no nodeids identical in stats1 and stats2 - .and_modify(|entry| entry.extend(stat2.clone().into_iter())) + .and_modify(|entry| entry.extend(stat2.clone())) .or_insert(stat2); } diff --git a/rs/recovery/src/app_subnet_recovery.rs b/rs/recovery/src/app_subnet_recovery.rs index 214fc6a201cf..e2f452e26131 100644 --- a/rs/recovery/src/app_subnet_recovery.rs +++ b/rs/recovery/src/app_subnet_recovery.rs @@ -313,6 +313,7 @@ impl RecoveryIterator for AppSubnetRecovery { wait_for_confirmation(&self.logger); } + #[allow(clippy::collapsible_match)] StepType::DownloadConsensusPool => { if self.params.download_pool_node.is_none() { // We could pick a node with highest finalization and CUP height automatically, @@ -354,6 +355,7 @@ impl RecoveryIterator for AppSubnetRecovery { } } + #[allow(clippy::collapsible_match)] StepType::ICReplay => { if self.params.replay_until_height.is_none() { self.params.replay_until_height = @@ -361,6 +363,7 @@ impl RecoveryIterator for AppSubnetRecovery { } } + #[allow(clippy::collapsible_match)] StepType::ElectVersion => { if self.params.upgrade_version.is_none() { self.params.upgrade_version = @@ -368,6 +371,7 @@ impl RecoveryIterator for AppSubnetRecovery { } } + #[allow(clippy::collapsible_match)] StepType::UpgradeVersion => { if self.params.upgrade_version.is_none() { self.params.upgrade_version = read_optional( @@ -398,6 +402,7 @@ impl RecoveryIterator for AppSubnetRecovery { } } + #[allow(clippy::collapsible_match)] StepType::UploadState => { if self.params.upload_method.is_none() { self.params.upload_method = Some(read_data_location( @@ -407,6 +412,7 @@ impl RecoveryIterator for AppSubnetRecovery { } } + #[allow(clippy::collapsible_match)] StepType::WaitForCUP => { if self.params.wait_for_cup_node.is_none() { if let Some(DataLocation::Remote(ip)) = self.params.upload_method { diff --git a/rs/recovery/src/nns_recovery_failover_nodes.rs b/rs/recovery/src/nns_recovery_failover_nodes.rs index 8f364666a3c3..11e5f0420340 100644 --- a/rs/recovery/src/nns_recovery_failover_nodes.rs +++ b/rs/recovery/src/nns_recovery_failover_nodes.rs @@ -184,6 +184,7 @@ impl RecoveryIterator for NNSRecoveryFailoverNodes { // Depending on the next step we might require some user interaction before we can execute // it. match step_type { + #[allow(clippy::collapsible_match)] StepType::StopReplica | StepType::DownloadConsensusPool | StepType::DownloadState => { if self.params.download_node.is_none() { // We could pick a node with highest finalization and CUP height automatically, @@ -200,6 +201,7 @@ impl RecoveryIterator for NNSRecoveryFailoverNodes { _ => {} } match step_type { + #[allow(clippy::collapsible_match)] StepType::DownloadState => { if self.params.download_state_height.is_none() { self.params.download_state_height = read_optional( @@ -223,6 +225,7 @@ impl RecoveryIterator for NNSRecoveryFailoverNodes { } } + #[allow(clippy::collapsible_match)] StepType::DownloadParentNNSStore => { if self.params.parent_nns_host_ip.is_none() { self.params.parent_nns_host_ip = read_optional( @@ -232,6 +235,7 @@ impl RecoveryIterator for NNSRecoveryFailoverNodes { } } + #[allow(clippy::collapsible_match)] StepType::ICReplayWithRegistryContent => { if self.params.replay_until_height.is_none() { self.params.replay_until_height = @@ -256,6 +260,7 @@ impl RecoveryIterator for NNSRecoveryFailoverNodes { } } + #[allow(clippy::collapsible_match)] StepType::WaitForCUP => { if self.params.upload_method.is_none() { self.params.upload_method = read_optional_data_location( diff --git a/rs/recovery/src/nns_recovery_same_nodes.rs b/rs/recovery/src/nns_recovery_same_nodes.rs index 9ae3c9274945..c3570ce0473d 100644 --- a/rs/recovery/src/nns_recovery_same_nodes.rs +++ b/rs/recovery/src/nns_recovery_same_nodes.rs @@ -244,6 +244,7 @@ impl RecoveryIterator for NNSRecoverySameNodes { // Depending on the next step we might require some user interaction before we can execute // it. match step_type { + #[allow(clippy::collapsible_match)] StepType::StopReplica | StepType::DownloadState | StepType::UploadState => { if self.params.admin_access_location.is_none() { self.params.admin_access_location = Some(read_data_location( @@ -255,6 +256,7 @@ impl RecoveryIterator for NNSRecoverySameNodes { _ => {} } match step_type { + #[allow(clippy::collapsible_match)] StepType::DownloadConsensusPool => { if self.params.download_pool_node.is_none() { // We could pick a node with highest finalization and CUP height automatically, @@ -310,6 +312,7 @@ impl RecoveryIterator for NNSRecoverySameNodes { } } + #[allow(clippy::collapsible_match)] StepType::CreateArtifacts => { if self.params.output_dir.is_none() { self.params.output_dir = read_optional( @@ -322,6 +325,7 @@ impl RecoveryIterator for NNSRecoverySameNodes { } } + #[allow(clippy::collapsible_match)] StepType::UploadCUPAndRegistry => { if self.params.wait_for_cup_node.is_none() { self.params.wait_for_cup_node = if let Some(DataLocation::Remote(ip)) = diff --git a/rs/recovery/subnet_splitting/src/subnet_splitting.rs b/rs/recovery/subnet_splitting/src/subnet_splitting.rs index f6161a7df460..ef042f375b1a 100644 --- a/rs/recovery/subnet_splitting/src/subnet_splitting.rs +++ b/rs/recovery/subnet_splitting/src/subnet_splitting.rs @@ -445,6 +445,7 @@ impl RecoveryIterator for SubnetSplitting { )); } + #[allow(clippy::collapsible_match)] StepType::UploadStateToSourceSubnet => { if self.params.upload_node_source.is_none() { self.params.upload_node_source = read_optional( @@ -454,6 +455,7 @@ impl RecoveryIterator for SubnetSplitting { } } + #[allow(clippy::collapsible_match)] StepType::UploadStateToDestinationSubnet => { if self.params.upload_node_destination.is_none() { self.params.upload_node_destination = read_optional( diff --git a/rs/registry/canister/src/invariants/assignment.rs b/rs/registry/canister/src/invariants/assignment.rs index d2a3fd1e9af6..00058bbc7a66 100644 --- a/rs/registry/canister/src/invariants/assignment.rs +++ b/rs/registry/canister/src/invariants/assignment.rs @@ -20,8 +20,8 @@ pub(crate) fn check_node_assignment_invariants( ) -> Result<(), InvariantCheckError> { // Replica let replicas: HashSet = get_subnet_records_map(snapshot) - .into_iter() - .flat_map(|(_, s)| s.membership) + .into_values() + .flat_map(|s| s.membership) .map(|v| NodeId::from(PrincipalId::try_from(v).unwrap())) .collect(); diff --git a/rs/registry/canister/src/mutations/firewall.rs b/rs/registry/canister/src/mutations/firewall.rs index b627576fdc5a..5760060cd432 100644 --- a/rs/registry/canister/src/mutations/firewall.rs +++ b/rs/registry/canister/src/mutations/firewall.rs @@ -156,7 +156,7 @@ pub fn add_firewall_rules_compute_entries( .collect(); // Add entries from the front to back (sorting with stable sort) - tuples.sort_by(|a, b| a.0.cmp(&b.0)); + tuples.sort_by_key(|a| a.0); for (already_inserted_above, (mut pos, rule)) in tuples.into_iter().enumerate() { // For every new entry we push the position down by the number of already-inserted entries. diff --git a/rs/registry/regedit/src/lib.rs b/rs/registry/regedit/src/lib.rs index db4051b5c362..b8da8783df0c 100644 --- a/rs/registry/regedit/src/lib.rs +++ b/rs/registry/regedit/src/lib.rs @@ -32,7 +32,7 @@ fn registry_spec_to_delta_pb( ) -> Result<(Vec, RegistryVersion)> { let (mut registry_changelogs, latest_registry_version) = source::get_changelog(source_spec)?; // Sort according to registry versions. - registry_changelogs.sort_by(|a, b| a.version.cmp(&b.version)); + registry_changelogs.sort_by_key(|a| a.version); // Clip registry versions that are not within requested interval. registry_changelogs.retain(|a| { a.version >= start_version diff --git a/rs/replicated_state/src/canister_state/queues.rs b/rs/replicated_state/src/canister_state/queues.rs index 944fa6b979af..0c0d49fc2a6e 100644 --- a/rs/replicated_state/src/canister_state/queues.rs +++ b/rs/replicated_state/src/canister_state/queues.rs @@ -663,10 +663,7 @@ impl CanisterQueues { F: FnMut(&CanisterId, &RequestOrResponse) -> Result<(), ()>, { for (canister_id, (_, queue)) in self.canister_queues.iter_mut() { - loop { - let Some(reference) = queue.peek() else { - break; - }; + while let Some(reference) = queue.peek() { let queue = Arc::make_mut(queue); let Some(msg) = self.store.pool.get(reference) else { // Expired / dropped message. Pop it and advance. diff --git a/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/src/blocks.rs b/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/src/blocks.rs index c0dab5a536a0..b63c0f7f57f7 100644 --- a/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/src/blocks.rs +++ b/rs/rosetta-api/icp/ledger_canister_blocks_synchronizer/src/blocks.rs @@ -1552,7 +1552,7 @@ impl Blocks { .take() .into_values() .collect(); - transactions.sort_by(|(idx1, _), (idx2, _)| idx1.cmp(idx2)); + transactions.sort_by_key(|(idx1, _)| *idx1); let rosetta_block = RosettaBlock { index: *current_rosetta_block_index.borrow(), parent_hash: current_rosetta_block_parent_hash diff --git a/rs/rosetta-api/icp/src/request_handler.rs b/rs/rosetta-api/icp/src/request_handler.rs index 395c55072202..b07d297e7dde 100644 --- a/rs/rosetta-api/icp/src/request_handler.rs +++ b/rs/rosetta-api/icp/src/request_handler.rs @@ -869,7 +869,7 @@ impl RosettaRequestHandler { }); // Sort the transactions by block index in descending order - transactions.sort_by(|a, b| b.block_identifier.index.cmp(&a.block_identifier.index)); + transactions.sort_by_key(|b| std::cmp::Reverse(b.block_identifier.index)); // If rosetta blocks is empty that means the entire blockchain was traversed but no transactions were found that match the search criteria let last_traversed_block_index = blocks.iter().map(|block| block.index).min().unwrap_or(0); diff --git a/rs/rosetta-api/icrc1/src/data_api/services.rs b/rs/rosetta-api/icrc1/src/data_api/services.rs index 7c26ae259239..70dc4674dfc2 100644 --- a/rs/rosetta-api/icrc1/src/data_api/services.rs +++ b/rs/rosetta-api/icrc1/src/data_api/services.rs @@ -514,7 +514,7 @@ pub async fn search_transactions( }); // Sort the transactions by block index in descending order - transactions.sort_by(|a, b| b.block_identifier.index.cmp(&a.block_identifier.index)); + transactions.sort_by_key(|b| std::cmp::Reverse(b.block_identifier.index)); // Is rosetta blocks is empty that means the entire blockchain was traversed but no transactions were found that match the search criteria let last_traversed_block_index = rosetta_blocks diff --git a/rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs b/rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs index 5aa2faaa0f15..c91d6b07436b 100644 --- a/rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs +++ b/rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs @@ -1581,6 +1581,7 @@ fn test_account_balance() { let mut all_involved_accounts = HashSet::new(); + #[allow(clippy::explicit_counter_loop)] for ArgWithCaller { caller, arg, diff --git a/rs/rosetta-api/icrc1/tests/system_tests.rs b/rs/rosetta-api/icrc1/tests/system_tests.rs index 48fdccba3c1f..e0d8f36014f3 100644 --- a/rs/rosetta-api/icrc1/tests/system_tests.rs +++ b/rs/rosetta-api/icrc1/tests/system_tests.rs @@ -1312,6 +1312,7 @@ fn test_account_balance() { let mut all_involved_accounts = HashSet::new(); + #[allow(clippy::explicit_counter_loop)] for ArgWithCaller { caller, arg, diff --git a/rs/rust_canisters/messaging_test/src/main.rs b/rs/rust_canisters/messaging_test/src/main.rs index c2d214a33bee..53b012cd6414 100644 --- a/rs/rust_canisters/messaging_test/src/main.rs +++ b/rs/rust_canisters/messaging_test/src/main.rs @@ -71,7 +71,7 @@ async fn handle_call((msg, bytes_received_on_call, _): (CallMessage, u32, u32)) // Perform and await the downstream calls; collect the responses. let downstream_replies = (futures::future::join_all(futures).await) .into_iter() - .zip(calls.into_iter()) + .zip(calls) .map(|(reply, call)| match reply { Ok(reply) => { let (reply, bytes_sent_on_reply, _) = decode::(reply.into_bytes()); diff --git a/rs/sns/governance/src/following.rs b/rs/sns/governance/src/following.rs index aaebd8e1bcf9..d4fd5f5130b8 100644 --- a/rs/sns/governance/src/following.rs +++ b/rs/sns/governance/src/following.rs @@ -490,7 +490,7 @@ impl TopicFollowees { ValidatedFolloweesForTopic::try_from(followees_for_topic.clone()) .map_err(SetFollowingError::InvalidExistingFollowing)?; - all_followees.extend(followees_for_topic.followees.into_iter()); + all_followees.extend(followees_for_topic.followees); } continue; diff --git a/rs/sns/governance/src/proposal.rs b/rs/sns/governance/src/proposal.rs index 59c89064296a..4f9ac89caa94 100644 --- a/rs/sns/governance/src/proposal.rs +++ b/rs/sns/governance/src/proposal.rs @@ -1092,7 +1092,7 @@ async fn validate_and_render_upgrade_sns_controlled_canister( } Ok(wasm) => match wasm.validate(env, canister_upgrade_arg).await { Err(new_defects) => { - defects.extend(new_defects.into_iter()); + defects.extend(new_defects); None } Ok(_) => Some(wasm.description()), diff --git a/rs/state_machine_tests/src/lib.rs b/rs/state_machine_tests/src/lib.rs index ea70340d9577..afeb76c6b170 100644 --- a/rs/state_machine_tests/src/lib.rs +++ b/rs/state_machine_tests/src/lib.rs @@ -2763,7 +2763,7 @@ impl StateMachine { contents: Vec, ) { assert_eq!(contents.len(), self.nodes.len()); - for (node, content) in std::iter::zip(self.nodes.iter(), contents.into_iter()) { + for (node, content) in std::iter::zip(self.nodes.iter(), contents) { let registry_version = self.registry_client.get_latest_version(); let response = CanisterHttpResponse { id: CanisterHttpRequestId::from(request_id), diff --git a/rs/state_manager/src/checkpoint.rs b/rs/state_manager/src/checkpoint.rs index 296693a14410..19b22449635f 100644 --- a/rs/state_manager/src/checkpoint.rs +++ b/rs/state_manager/src/checkpoint.rs @@ -586,8 +586,8 @@ impl CheckpointLoader { format!("Snapshot validation: failed to load list of snapshot ids: {err}") })?; let mut ref_snapshot_ids: Vec<_> = ref_canister_snapshots - .iter() - .flat_map(|(_, x)| x.iter().map(|x| *x.0)) + .values() + .flat_map(|x| x.iter().map(|x| *x.0)) .collect(); on_disk_snapshot_ids.sort(); ref_snapshot_ids.sort(); diff --git a/rs/tests/ckbtc/ckdoge_minter_basics_test.rs b/rs/tests/ckbtc/ckdoge_minter_basics_test.rs index 6423f1bbb286..ffebc89df480 100644 --- a/rs/tests/ckbtc/ckdoge_minter_basics_test.rs +++ b/rs/tests/ckbtc/ckdoge_minter_basics_test.rs @@ -307,6 +307,7 @@ async fn test_retrieve_doge_status bool>( RetrieveDogeStatus::Confirmed { txid } => { return txid; } + #[allow(clippy::collapsible_match)] RetrieveDogeStatus::Submitted { txid } => { if !blocks_generated { use bitcoin::hashes::Hash; diff --git a/rs/tests/ckbtc/src/adapter.rs b/rs/tests/ckbtc/src/adapter.rs index d151c4a987e5..758f1a96b79c 100644 --- a/rs/tests/ckbtc/src/adapter.rs +++ b/rs/tests/ckbtc/src/adapter.rs @@ -228,7 +228,7 @@ impl<'a, T: IcRpcClientType> AdapterProxy<'a, T> { // Flatten the partial block into a single Vec let reconstructed_block = std::iter::once(partial_block) - .chain(results.into_iter()) + .chain(results) .flatten() .collect::>(); diff --git a/rs/tests/dre/utils/steps/update_subnet_type.rs b/rs/tests/dre/utils/steps/update_subnet_type.rs index c7523dae6927..46b74874ca84 100644 --- a/rs/tests/dre/utils/steps/update_subnet_type.rs +++ b/rs/tests/dre/utils/steps/update_subnet_type.rs @@ -225,11 +225,7 @@ async fn assert_version_on_all_nodes( }) }); - if join_all(threads.into_iter()) - .await - .iter() - .any(|r| r.is_err()) - { + if join_all(threads).await.iter().any(|r| r.is_err()) { anyhow::bail!( "Failed to ensure replica version {} on the current subnet", version diff --git a/rs/tests/message_routing/xnet/slo_test_lib/xnet_slo_test_lib.rs b/rs/tests/message_routing/xnet/slo_test_lib/xnet_slo_test_lib.rs index 8a1acb4bd544..11a9b4bd5b24 100644 --- a/rs/tests/message_routing/xnet/slo_test_lib/xnet_slo_test_lib.rs +++ b/rs/tests/message_routing/xnet/slo_test_lib/xnet_slo_test_lib.rs @@ -444,8 +444,11 @@ pub fn check_success( &actual, ); - if responses_received != 0 { - let avg_latency_millis = m.latency_distribution.sum_millis() / responses_received; + if let Some(avg_latency_millis) = m + .latency_distribution + .sum_millis() + .checked_div(responses_received) + { expect( avg_latency_millis <= config.targeted_latency_seconds as usize * 1000, i, diff --git a/rs/tests/networking/http_endpoints_public_spec_test.rs b/rs/tests/networking/http_endpoints_public_spec_test.rs index 8b22d51dc11f..634d759a0b9b 100644 --- a/rs/tests/networking/http_endpoints_public_spec_test.rs +++ b/rs/tests/networking/http_endpoints_public_spec_test.rs @@ -301,7 +301,7 @@ fn malformed_http_request(env: TestEnv) { Value::Text("request_type".to_string()) => Value::Text(request_type.to_string()), Value::Text("sender".to_string()) => Value::Bytes(Principal::anonymous().as_slice().to_vec()), }; - valid_content.extend(content.into_iter()); + valid_content.extend(content); let envelope = |mut content: BTreeMap| { let ingress_expiry = SystemTime::now().duration_since(UNIX_EPOCH).unwrap() + Duration::from_secs(3 * 60); diff --git a/rs/types/types/src/consensus/idkg.rs b/rs/types/types/src/consensus/idkg.rs index 440ae7087c2f..8fc0746bddaf 100644 --- a/rs/types/types/src/consensus/idkg.rs +++ b/rs/types/types/src/consensus/idkg.rs @@ -228,8 +228,8 @@ impl IDkgPayload { .flat_map(MasterKeyTranscript::transcript_config_in_creation); self.pre_signatures_in_creation - .iter() - .flat_map(|(_, pre_sig)| pre_sig.iter_transcript_configs_in_creation()) + .values() + .flat_map(|pre_sig| pre_sig.iter_transcript_configs_in_creation()) .chain(key_transcripts) .chain(xnet_reshares_transcripts) } @@ -240,8 +240,8 @@ impl IDkgPayload { &self, ) -> impl Iterator + '_ { self.pre_signatures_in_creation - .iter() - .flat_map(|(_, pre_sig)| pre_sig.iter_transcript_configs_in_creation()) + .values() + .flat_map(|pre_sig| pre_sig.iter_transcript_configs_in_creation()) } /// Return an iterator of the ongoing xnet reshare transcripts on the source side. diff --git a/rs/xnet/payload_builder/src/proximity.rs b/rs/xnet/payload_builder/src/proximity.rs index 065e9f947014..59e4b0770137 100644 --- a/rs/xnet/payload_builder/src/proximity.rs +++ b/rs/xnet/payload_builder/src/proximity.rs @@ -160,11 +160,7 @@ impl ProximityMap { } // Mean weight to assign to nodes that we don't have explicit weights for. - let mean_weight = if weighted_nodes > 0 { - total_weight / weighted_nodes - } else { - 1 - }; + let mean_weight = total_weight.checked_div(weighted_nodes).unwrap_or(1); // Cumulative node weights, to be used for weighted random selection. let cumulative_weights: Vec = node_weights