From e92edd6724353938880f3797b4ce41da273624f8 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 16 Mar 2022 13:39:05 +0100 Subject: [PATCH] chore: update toolchain version to nightly 1.59 (#339) * chore: bump up toolchain to nightly 1.59 * chore: address Clippy warnings (cherry picked from commit 80182c58a80779e16215249073c167c33c511b89) --- pallets/attestation/src/mock.rs | 5 +++++ pallets/delegation/src/mock.rs | 4 ++++ pallets/parachain-staking/src/lib.rs | 5 ++--- pallets/parachain-staking/src/tests.rs | 4 ++-- rust-toolchain.toml | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index 8b0d75226..3eb90fdbb 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -291,6 +291,7 @@ pub(crate) mod runtime { } impl ExtBuilder { + #[must_use] pub fn with_delegation_hierarchies( mut self, delegation_hierarchies: DelegationHierarchyInitialization, @@ -299,21 +300,25 @@ pub(crate) mod runtime { self } + #[must_use] pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { self.delegations = delegations; self } + #[must_use] pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, CtypeCreatorOf)>) -> Self { self.ctypes = ctypes; self } + #[must_use] pub fn with_balances(mut self, balances: Vec<(AccountIdOf, BalanceOf)>) -> Self { self.balances = balances; self } + #[must_use] pub fn with_attestations(mut self, attestations: Vec<(TestClaimHash, AttestationDetails)>) -> Self { self.attestations = attestations; self diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index 8167aeb28..6be1a55f5 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -412,6 +412,7 @@ pub mod runtime { } impl ExtBuilder { + #[must_use] pub fn with_delegation_hierarchies( mut self, delegation_hierarchies: DelegationHierarchyInitialization, @@ -420,16 +421,19 @@ pub mod runtime { self } + #[must_use] pub fn with_balances(mut self, balances: Vec<(AccountIdOf, BalanceOf)>) -> Self { self.balances = balances; self } + #[must_use] pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, SubjectId)>) -> Self { self.ctypes = ctypes; self } + #[must_use] pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { self.delegations_stored = delegations; self diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index bca68d218..dabc1bdcd 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1485,7 +1485,7 @@ pub mod pallet { ensure!(amount >= T::MinDelegatorStake::get(), Error::::NomStakeBelowMin); // cannot be a collator candidate and delegator with same AccountId - ensure!(!Self::is_active_candidate(&acc).is_some(), Error::::CandidateExists); + ensure!(Self::is_active_candidate(&acc).is_none(), Error::::CandidateExists); ensure!( Unstaking::::get(&acc).len().saturated_into::() < T::MaxUnstakeRequests::get(), Error::::CannotJoinBeforeUnlocking @@ -2139,8 +2139,7 @@ pub mod pallet { ) -> Option<(BalanceOf, BalanceOf)> { top_candidates .get(index) - .map(|stake| CandidatePool::::get(&stake.owner)) - .flatten() + .and_then(|stake| CandidatePool::::get(&stake.owner)) // SAFETY: the total is always more than the stake .map(|state| (state.stake, state.total - state.stake)) } diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index 8a1f3baef..f9ead1d48 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -887,7 +887,7 @@ fn execute_leave_candidates_with_delay() { *collator )); assert!(StakePallet::candidate_pool(&collator).is_none()); - assert!(!StakePallet::is_active_candidate(collator).is_some()); + assert!(StakePallet::is_active_candidate(collator).is_none()); assert_eq!(StakePallet::unstaking(collator).len(), 1); } assert_eq!(CandidatePool::::count(), 5, "Five collators left."); @@ -906,7 +906,7 @@ fn execute_leave_candidates_with_delay() { collator )); assert!(StakePallet::candidate_pool(&collator).is_none()); - assert!(!StakePallet::is_active_candidate(&collator).is_some()); + assert!(StakePallet::is_active_candidate(&collator).is_none()); assert_eq!(StakePallet::unstaking(collator).len(), 1); } assert_eq!(CandidatePool::::count(), 2, "3 collators left."); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 810eebdb0..fb3e5de51 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2021-11-08" +channel = "nightly-2022-01-08" targets = [ "wasm32-unknown-unknown" ]