From a58f04eabb726f126c00619d02620fac23627ee7 Mon Sep 17 00:00:00 2001 From: Squirrel Date: Tue, 6 Feb 2024 13:01:29 +0000 Subject: [PATCH] sp-std -> core (#3199) First in a series of PRs that reduces our use of sp-std with a view to deprecating it. This is just looking at /substrate and moving some of the references from `sp-std` to `core`. These particular changes should be uncontroversial. Where macros are used `::core` should be used to remove any ambiguity. part of https://github.com/paritytech/polkadot-sdk/issues/2101 --- substrate/frame/alliance/src/benchmarking.rs | 5 ++--- substrate/frame/alliance/src/mock.rs | 2 +- substrate/frame/asset-conversion/src/mock.rs | 2 +- substrate/frame/asset-conversion/src/types.rs | 2 +- substrate/frame/assets/src/extra_mutator.rs | 6 +++--- substrate/frame/assets/src/migration.rs | 2 +- substrate/frame/assets/src/types.rs | 4 ++-- substrate/frame/atomic-swap/src/lib.rs | 9 ++++----- substrate/frame/aura/src/migrations.rs | 2 +- substrate/frame/babe/src/randomness.rs | 8 ++++---- substrate/frame/bounties/src/migrations/v4.rs | 2 +- substrate/frame/collective/src/benchmarking.rs | 2 +- substrate/frame/contracts/src/gas.rs | 2 +- substrate/frame/contracts/src/migration/v10.rs | 7 +++++-- substrate/frame/contracts/src/schedule.rs | 2 +- .../frame/core-fellowship/src/tests/unit.rs | 2 +- substrate/frame/democracy/src/conviction.rs | 2 +- substrate/frame/democracy/src/migrations/v1.rs | 2 +- substrate/frame/democracy/src/vote_threshold.rs | 2 +- .../src/benchmarking.rs | 2 +- .../frame/election-provider-support/src/tests.rs | 2 +- .../election-provider-support/src/weights.rs | 2 +- substrate/frame/examples/basic/src/lib.rs | 9 +++++---- substrate/frame/examples/basic/src/weights.rs | 2 +- substrate/frame/grandpa/src/migrations.rs | 2 +- substrate/frame/im-online/src/migration.rs | 2 +- .../frame/merkle-mountain-range/src/mmr/mod.rs | 2 +- substrate/frame/multisig/src/migrations.rs | 2 +- substrate/frame/nfts/src/macros.rs | 2 +- substrate/frame/nfts/src/migration.rs | 2 +- .../frame/node-authorization/src/weights.rs | 2 +- substrate/frame/nomination-pools/src/tests.rs | 2 +- substrate/frame/referenda/src/types.rs | 2 +- substrate/frame/safe-mode/src/lib.rs | 2 +- substrate/frame/salary/src/lib.rs | 2 +- substrate/frame/salary/src/tests/unit.rs | 2 +- substrate/frame/sassafras/src/mock.rs | 2 +- substrate/frame/scheduler/src/migration.rs | 4 ++-- substrate/frame/session/src/migrations/v1.rs | 2 +- substrate/frame/society/src/migrations.rs | 2 +- substrate/frame/society/src/weights.rs | 2 +- .../frame/staking/src/election_size_tracker.rs | 2 +- substrate/frame/staking/src/migrations.rs | 10 +++++----- .../src/construct_runtime/expand/call.rs | 2 +- .../src/construct_runtime/expand/outer_enums.rs | 4 +--- .../support/procedural/src/pallet/expand/call.rs | 2 +- .../procedural/src/pallet/expand/event.rs | 2 +- .../procedural/src/pallet/parse/composite.rs | 2 +- .../support/procedural/src/storage_alias.rs | 4 ++-- substrate/frame/support/src/tests/mod.rs | 2 +- substrate/frame/support/src/traits/dispatch.rs | 14 +++++++------- substrate/frame/support/src/traits/error.rs | 2 +- substrate/frame/support/src/traits/stored_map.rs | 2 +- .../frame/support/src/traits/tokens/currency.rs | 4 ++-- .../frame/support/src/traits/tokens/imbalance.rs | 2 +- substrate/frame/tips/src/migrations/v4.rs | 2 +- .../frame/transaction-payment/src/payment.rs | 2 +- substrate/frame/uniques/src/migration.rs | 2 +- .../api/proc-macro/src/impl_runtime_apis.rs | 4 ++-- .../primitives/arithmetic/src/helpers_128bit.rs | 2 +- substrate/primitives/arithmetic/src/traits.rs | 16 ++++++++-------- .../primitives/consensus/aura/src/inherents.rs | 2 +- .../primitives/consensus/babe/src/inherents.rs | 4 ++-- substrate/primitives/consensus/slots/src/lib.rs | 6 +++--- substrate/primitives/core/src/testing.rs | 4 ++-- .../primitives/runtime-interface/src/util.rs | 4 ++-- .../primitives/runtime-interface/src/wasm.rs | 2 +- .../primitives/runtime/src/generic/header.rs | 2 +- .../runtime/src/offchain/storage_lock.rs | 2 +- substrate/primitives/state-machine/src/error.rs | 2 +- .../state-machine/src/in_memory_backend.rs | 2 +- substrate/primitives/state-machine/src/stats.rs | 2 +- substrate/primitives/timestamp/src/lib.rs | 6 +++--- substrate/primitives/trie/src/node_header.rs | 6 +++--- substrate/primitives/weights/src/lib.rs | 6 +++--- 75 files changed, 125 insertions(+), 125 deletions(-) diff --git a/substrate/frame/alliance/src/benchmarking.rs b/substrate/frame/alliance/src/benchmarking.rs index b69d0156ec4b0..9fe0e29b42cd9 100644 --- a/substrate/frame/alliance/src/benchmarking.rs +++ b/substrate/frame/alliance/src/benchmarking.rs @@ -19,13 +19,12 @@ #![cfg(feature = "runtime-benchmarks")] -use sp_runtime::traits::{Bounded, Hash, StaticLookup}; -use sp_std::{ +use core::{ cmp, convert::{TryFrom, TryInto}, mem::size_of, - prelude::*, }; +use sp_runtime::traits::{Bounded, Hash, StaticLookup}; use frame_benchmarking::{account, impl_benchmark_test_suite, v2::*, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 627dde81afa84..4a65485ed8f66 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -17,13 +17,13 @@ //! Test utilities +use core::convert::{TryFrom, TryInto}; pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ traits::{BlakeTwo256, IdentifyAccount, Lazy, Verify}, BuildStorage, }; -use sp_std::convert::{TryFrom, TryInto}; pub use frame_support::{ assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types, diff --git a/substrate/frame/asset-conversion/src/mock.rs b/substrate/frame/asset-conversion/src/mock.rs index dd1d26ff238de..6c19f834cb8ff 100644 --- a/substrate/frame/asset-conversion/src/mock.rs +++ b/substrate/frame/asset-conversion/src/mock.rs @@ -19,6 +19,7 @@ use super::*; use crate as pallet_asset_conversion; +use core::default::Default; use frame_support::{ construct_runtime, derive_impl, instances::{Instance1, Instance2}, @@ -39,7 +40,6 @@ use sp_runtime::{ traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, BuildStorage, }; -use sp_std::default::Default; type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/asset-conversion/src/types.rs b/substrate/frame/asset-conversion/src/types.rs index fd6d41a55b613..5ee81c2012de2 100644 --- a/substrate/frame/asset-conversion/src/types.rs +++ b/substrate/frame/asset-conversion/src/types.rs @@ -17,8 +17,8 @@ use super::*; use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use scale_info::TypeInfo; -use sp_std::marker::PhantomData; /// Represents a swap path with associated asset amounts indicating how much of the asset needs to /// be deposited to get the following asset's amount withdrawn (this is inclusive of fees). diff --git a/substrate/frame/assets/src/extra_mutator.rs b/substrate/frame/assets/src/extra_mutator.rs index 2a44df5f0c661..e2f7742c694a3 100644 --- a/substrate/frame/assets/src/extra_mutator.rs +++ b/substrate/frame/assets/src/extra_mutator.rs @@ -38,7 +38,7 @@ impl, I: 'static> Drop for ExtraMutator { } } -impl, I: 'static> sp_std::ops::Deref for ExtraMutator { +impl, I: 'static> core::ops::Deref for ExtraMutator { type Target = T::Extra; fn deref(&self) -> &T::Extra { match self.pending { @@ -48,7 +48,7 @@ impl, I: 'static> sp_std::ops::Deref for ExtraMutator { } } -impl, I: 'static> sp_std::ops::DerefMut for ExtraMutator { +impl, I: 'static> core::ops::DerefMut for ExtraMutator { fn deref_mut(&mut self) -> &mut T::Extra { if self.pending.is_none() { self.pending = Some(self.original.clone()); @@ -60,7 +60,7 @@ impl, I: 'static> sp_std::ops::DerefMut for ExtraMutator { impl, I: 'static> ExtraMutator { pub(super) fn maybe_new( id: T::AssetId, - who: impl sp_std::borrow::Borrow, + who: impl core::borrow::Borrow, ) -> Option> { if let Some(a) = Account::::get(&id, who.borrow()) { Some(ExtraMutator:: { diff --git a/substrate/frame/assets/src/migration.rs b/substrate/frame/assets/src/migration.rs index efe77714c524d..ff0ffbff0d362 100644 --- a/substrate/frame/assets/src/migration.rs +++ b/substrate/frame/assets/src/migration.rs @@ -64,7 +64,7 @@ pub mod v1 { } } - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let current_version = Pallet::::current_storage_version(); diff --git a/substrate/frame/assets/src/types.rs b/substrate/frame/assets/src/types.rs index 67f9bf07f5e7e..11edc7d3fcb58 100644 --- a/substrate/frame/assets/src/types.rs +++ b/substrate/frame/assets/src/types.rs @@ -123,7 +123,7 @@ where return None } if let ExistenceReason::DepositHeld(deposit) = - sp_std::mem::replace(self, ExistenceReason::DepositRefunded) + core::mem::replace(self, ExistenceReason::DepositRefunded) { Some(deposit) } else { @@ -136,7 +136,7 @@ where return None } if let ExistenceReason::DepositFrom(depositor, deposit) = - sp_std::mem::replace(self, ExistenceReason::DepositRefunded) + core::mem::replace(self, ExistenceReason::DepositRefunded) { Some((depositor, deposit)) } else { diff --git a/substrate/frame/atomic-swap/src/lib.rs b/substrate/frame/atomic-swap/src/lib.rs index 8094c06030120..609903e67e3e5 100644 --- a/substrate/frame/atomic-swap/src/lib.rs +++ b/substrate/frame/atomic-swap/src/lib.rs @@ -43,6 +43,10 @@ mod tests; use codec::{Decode, Encode}; +use core::{ + marker::PhantomData, + ops::{Deref, DerefMut}, +}; use frame_support::{ dispatch::DispatchResult, pallet_prelude::MaxEncodedLen, @@ -54,11 +58,6 @@ use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::RuntimeDebug; -use sp_std::{ - marker::PhantomData, - ops::{Deref, DerefMut}, - prelude::*, -}; /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] diff --git a/substrate/frame/aura/src/migrations.rs b/substrate/frame/aura/src/migrations.rs index b45e4eb7cb5c8..727fe281aa384 100644 --- a/substrate/frame/aura/src/migrations.rs +++ b/substrate/frame/aura/src/migrations.rs @@ -19,7 +19,7 @@ use frame_support::{pallet_prelude::*, traits::Get, weights::Weight}; -struct __LastTimestamp(sp_std::marker::PhantomData); +struct __LastTimestamp(core::marker::PhantomData); impl frame_support::traits::StorageInstance for __LastTimestamp { fn pallet_prefix() -> &'static str { T::PalletPrefix::get() diff --git a/substrate/frame/babe/src/randomness.rs b/substrate/frame/babe/src/randomness.rs index d3d1bea2292da..fd52981d2a1dd 100644 --- a/substrate/frame/babe/src/randomness.rs +++ b/substrate/frame/babe/src/randomness.rs @@ -51,7 +51,7 @@ use sp_runtime::traits::{Hash, One, Saturating}; /// /// Adversaries should not possess many block production slots towards the beginning or /// end of every epoch, but they possess some influence over when they possess more slots. -pub struct RandomnessFromTwoEpochsAgo(sp_std::marker::PhantomData); +pub struct RandomnessFromTwoEpochsAgo(core::marker::PhantomData); /// Randomness usable by on-chain code that **does not depend** upon finality and takes /// action based upon on-chain commitments made during the previous epoch. @@ -79,7 +79,7 @@ pub struct RandomnessFromTwoEpochsAgo(sp_std::marker::PhantomData); /// As an example usage, we determine parachain auctions ending times in Polkadot using /// `RandomnessFromOneEpochAgo` because it reduces bias from `ParentBlockRandomness` and /// does not require the extra finality delay of `RandomnessFromTwoEpochsAgo`. -pub struct RandomnessFromOneEpochAgo(sp_std::marker::PhantomData); +pub struct RandomnessFromOneEpochAgo(core::marker::PhantomData); /// Randomness produced semi-freshly with each block, but inherits limitations of /// `RandomnessFromTwoEpochsAgo` from which it derives. @@ -119,7 +119,7 @@ pub struct RandomnessFromOneEpochAgo(sp_std::marker::PhantomData); /// instead you are using this randomness externally, i.e. after block execution, then /// this randomness will be provided by the "current" block (this stems from the fact that /// we process VRF outputs on block execution finalization, i.e. `on_finalize`). -pub struct ParentBlockRandomness(sp_std::marker::PhantomData); +pub struct ParentBlockRandomness(core::marker::PhantomData); /// Randomness produced semi-freshly with each block, but inherits limitations of /// `RandomnessFromTwoEpochsAgo` from which it derives. @@ -128,7 +128,7 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); #[deprecated(note = "Should not be relied upon for correctness, \ will not provide fresh randomness for the current block. \ Please use `ParentBlockRandomness` instead.")] -pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); +pub struct CurrentBlockRandomness(core::marker::PhantomData); impl RandomnessT> for RandomnessFromTwoEpochsAgo { fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { diff --git a/substrate/frame/bounties/src/migrations/v4.rs b/substrate/frame/bounties/src/migrations/v4.rs index 4e6ba93448162..71cd4f76be6e2 100644 --- a/substrate/frame/bounties/src/migrations/v4.rs +++ b/substrate/frame/bounties/src/migrations/v4.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::str; use frame_support::{ storage::{generator::StorageValue, StoragePrefixedMap}, traits::{ @@ -25,7 +26,6 @@ use frame_support::{ }; use sp_core::hexdisplay::HexDisplay; use sp_io::{hashing::twox_128, storage}; -use sp_std::str; use crate as pallet_bounties; diff --git a/substrate/frame/collective/src/benchmarking.rs b/substrate/frame/collective/src/benchmarking.rs index 503d725105309..af10eae5b673d 100644 --- a/substrate/frame/collective/src/benchmarking.rs +++ b/substrate/frame/collective/src/benchmarking.rs @@ -20,8 +20,8 @@ use super::*; use crate::Pallet as Collective; +use core::mem::size_of; use sp_runtime::traits::Bounded; -use sp_std::mem::size_of; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_system::{ diff --git a/substrate/frame/contracts/src/gas.rs b/substrate/frame/contracts/src/gas.rs index 363ddfad975b1..f78fb03a401db 100644 --- a/substrate/frame/contracts/src/gas.rs +++ b/substrate/frame/contracts/src/gas.rs @@ -16,6 +16,7 @@ // limitations under the License. use crate::{exec::ExecError, Config, Error}; +use core::marker::PhantomData; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo}, weights::Weight, @@ -23,7 +24,6 @@ use frame_support::{ }; use sp_core::Get; use sp_runtime::{traits::Zero, DispatchError}; -use sp_std::marker::PhantomData; #[cfg(test)] use std::{any::Any, fmt::Debug}; diff --git a/substrate/frame/contracts/src/migration/v10.rs b/substrate/frame/contracts/src/migration/v10.rs index 22fad38739e75..d64673aac7d26 100644 --- a/substrate/frame/contracts/src/migration/v10.rs +++ b/substrate/frame/contracts/src/migration/v10.rs @@ -25,7 +25,10 @@ use crate::{ CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; -use core::cmp::{max, min}; +use core::{ + cmp::{max, min}, + ops::Deref, +}; use frame_support::{ pallet_prelude::*, storage_alias, @@ -42,7 +45,7 @@ use sp_runtime::{ traits::{Hash, TrailingZeroInput, Zero}, Perbill, Saturating, }; -use sp_std::{ops::Deref, prelude::*}; +use sp_std::prelude::*; mod old { use super::*; diff --git a/substrate/frame/contracts/src/schedule.rs b/substrate/frame/contracts/src/schedule.rs index 51c7c0bd9dd1f..63641832315ee 100644 --- a/substrate/frame/contracts/src/schedule.rs +++ b/substrate/frame/contracts/src/schedule.rs @@ -21,11 +21,11 @@ use crate::{weights::WeightInfo, Config}; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::{weights::Weight, DefaultNoBound}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sp_std::marker::PhantomData; /// Definition of the cost schedule and other parameterizations for the wasm vm. /// diff --git a/substrate/frame/core-fellowship/src/tests/unit.rs b/substrate/frame/core-fellowship/src/tests/unit.rs index 52a31e5e106f2..de8cd858bdfc0 100644 --- a/substrate/frame/core-fellowship/src/tests/unit.rs +++ b/substrate/frame/core-fellowship/src/tests/unit.rs @@ -19,6 +19,7 @@ use std::collections::BTreeMap; +use core::cell::RefCell; use frame_support::{ assert_noop, assert_ok, derive_impl, ord_parameter_types, pallet_prelude::Weight, @@ -27,7 +28,6 @@ use frame_support::{ }; use frame_system::EnsureSignedBy; use sp_runtime::{traits::TryMorphInto, BuildStorage, DispatchError, DispatchResult}; -use sp_std::cell::RefCell; use crate as pallet_core_fellowship; use crate::*; diff --git a/substrate/frame/democracy/src/conviction.rs b/substrate/frame/democracy/src/conviction.rs index d2f685f7d99ef..54f4ff524f2a9 100644 --- a/substrate/frame/democracy/src/conviction.rs +++ b/substrate/frame/democracy/src/conviction.rs @@ -19,12 +19,12 @@ use crate::types::Delegations; use codec::{Decode, Encode, MaxEncodedLen}; +use core::result::Result; use scale_info::TypeInfo; use sp_runtime::{ traits::{Bounded, CheckedDiv, CheckedMul, Zero}, RuntimeDebug, }; -use sp_std::{prelude::*, result::Result}; /// A value denoting the strength of conviction of a vote. #[derive( diff --git a/substrate/frame/democracy/src/migrations/v1.rs b/substrate/frame/democracy/src/migrations/v1.rs index 64baea8f3af70..5e423b9ab6eff 100644 --- a/substrate/frame/democracy/src/migrations/v1.rs +++ b/substrate/frame/democracy/src/migrations/v1.rs @@ -54,7 +54,7 @@ pub mod v1 { use super::*; /// Migration for translating bare `Hash`es into `Bounded`s. - pub struct Migration(sp_std::marker::PhantomData); + pub struct Migration(core::marker::PhantomData); impl> OnRuntimeUpgrade for Migration { #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/democracy/src/vote_threshold.rs b/substrate/frame/democracy/src/vote_threshold.rs index e8efa179ed8bf..82d6ed178f137 100644 --- a/substrate/frame/democracy/src/vote_threshold.rs +++ b/substrate/frame/democracy/src/vote_threshold.rs @@ -19,11 +19,11 @@ use crate::Tally; use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::{Add, Div, Mul, Rem}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::traits::{IntegerSquareRoot, Zero}; -use sp_std::ops::{Add, Div, Mul, Rem}; /// A means of determining if a vote is past pass threshold. #[derive( diff --git a/substrate/frame/election-provider-multi-phase/src/benchmarking.rs b/substrate/frame/election-provider-multi-phase/src/benchmarking.rs index 4a2855f1361f2..957ae51b8f1da 100644 --- a/substrate/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/substrate/frame/election-provider-multi-phase/src/benchmarking.rs @@ -496,7 +496,7 @@ frame_benchmarking::benchmarks! { let (_, stake, _) = voters[*idx]; stake }).unwrap_or_default(); - sp_std::cmp::Reverse(stake) + core::cmp::Reverse(stake) }); let mut index_assignments = assignments diff --git a/substrate/frame/election-provider-support/src/tests.rs b/substrate/frame/election-provider-support/src/tests.rs index 73ce1427cf2f0..6e3deb9e38346 100644 --- a/substrate/frame/election-provider-support/src/tests.rs +++ b/substrate/frame/election-provider-support/src/tests.rs @@ -29,7 +29,7 @@ mod solution_type { // these need to come from the same dev-dependency `frame-election-provider-support`, not from // the crate. use crate::{generate_solution_type, Assignment, Error as NposError, NposSolution}; - use sp_std::fmt::Debug; + use core::fmt::Debug; #[allow(dead_code)] mod __private { diff --git a/substrate/frame/election-provider-support/src/weights.rs b/substrate/frame/election-provider-support/src/weights.rs index addb6ad8d0306..09b0cb108f7fa 100644 --- a/substrate/frame/election-provider-support/src/weights.rs +++ b/substrate/frame/election-provider-support/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_election_provider_support_benchmarking. pub trait WeightInfo { diff --git a/substrate/frame/examples/basic/src/lib.rs b/substrate/frame/examples/basic/src/lib.rs index 5eff74922cabf..dad4d01978f95 100644 --- a/substrate/frame/examples/basic/src/lib.rs +++ b/substrate/frame/examples/basic/src/lib.rs @@ -54,6 +54,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::{ dispatch::{ClassifyDispatch, DispatchClass, DispatchResult, Pays, PaysFee, WeighData}, traits::IsSubType, @@ -68,7 +69,7 @@ use sp_runtime::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }, }; -use sp_std::{marker::PhantomData, prelude::*}; +use sp_std::vec::Vec; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; @@ -485,8 +486,8 @@ impl Pallet { #[scale_info(skip_type_params(T))] pub struct WatchDummy(PhantomData); -impl sp_std::fmt::Debug for WatchDummy { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { +impl core::fmt::Debug for WatchDummy { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "WatchDummy") } } @@ -501,7 +502,7 @@ where type AdditionalSigned = (); type Pre = (); - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/examples/basic/src/weights.rs b/substrate/frame/examples/basic/src/weights.rs index def944054cce8..dbb9170aa67e0 100644 --- a/substrate/frame/examples/basic/src/weights.rs +++ b/substrate/frame/examples/basic/src/weights.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_example_basic. pub trait WeightInfo { diff --git a/substrate/frame/grandpa/src/migrations.rs b/substrate/frame/grandpa/src/migrations.rs index 3a484eb60d284..9d0522c3a6e72 100644 --- a/substrate/frame/grandpa/src/migrations.rs +++ b/substrate/frame/grandpa/src/migrations.rs @@ -35,7 +35,7 @@ mod v5; /// This migration should be added with a runtime upgrade that introduces the /// `MaxSetIdSessionEntries` constant to the pallet (although it could also be /// done later on). -pub struct CleanupSetIdSessionMap(sp_std::marker::PhantomData); +pub struct CleanupSetIdSessionMap(core::marker::PhantomData); impl OnRuntimeUpgrade for CleanupSetIdSessionMap { fn on_runtime_upgrade() -> Weight { // NOTE: since this migration will loop over all stale entries in the diff --git a/substrate/frame/im-online/src/migration.rs b/substrate/frame/im-online/src/migration.rs index 84652965972e3..3860a7ca53295 100644 --- a/substrate/frame/im-online/src/migration.rs +++ b/substrate/frame/im-online/src/migration.rs @@ -56,7 +56,7 @@ pub mod v1 { use super::*; /// Simple migration that replaces `ReceivedHeartbeats` values with `true`. - pub struct Migration(sp_std::marker::PhantomData); + pub struct Migration(core::marker::PhantomData); impl OnRuntimeUpgrade for Migration { #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/merkle-mountain-range/src/mmr/mod.rs b/substrate/frame/merkle-mountain-range/src/mmr/mod.rs index 536faa68e4e9f..93fefe910e45d 100644 --- a/substrate/frame/merkle-mountain-range/src/mmr/mod.rs +++ b/substrate/frame/merkle-mountain-range/src/mmr/mod.rs @@ -30,7 +30,7 @@ pub type NodeOf = Node<>::Hashing, L>; pub type Node = DataOrHash; /// Default Merging & Hashing behavior for MMR. -pub struct Hasher(sp_std::marker::PhantomData<(H, L)>); +pub struct Hasher(core::marker::PhantomData<(H, L)>); impl mmr_lib::Merge for Hasher { type Item = Node; diff --git a/substrate/frame/multisig/src/migrations.rs b/substrate/frame/multisig/src/migrations.rs index 330613bb3dfda..d03e42a66a5b5 100644 --- a/substrate/frame/multisig/src/migrations.rs +++ b/substrate/frame/multisig/src/migrations.rs @@ -39,7 +39,7 @@ pub mod v1 { (OpaqueCall, ::AccountId, BalanceOf), >; - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/substrate/frame/nfts/src/macros.rs b/substrate/frame/nfts/src/macros.rs index 1a601ce0927fa..d313c8785b271 100644 --- a/substrate/frame/nfts/src/macros.rs +++ b/substrate/frame/nfts/src/macros.rs @@ -42,7 +42,7 @@ macro_rules! impl_codec_bitflags { impl Decode for $wrapper { fn decode( input: &mut I, - ) -> sp_std::result::Result { + ) -> ::core::result::Result { let field = <$size>::decode(input)?; Ok(Self(BitFlags::from_bits(field as $size).map_err(|_| "invalid value")?)) } diff --git a/substrate/frame/nfts/src/migration.rs b/substrate/frame/nfts/src/migration.rs index 94635a96aeba9..d4cdf7e820d15 100644 --- a/substrate/frame/nfts/src/migration.rs +++ b/substrate/frame/nfts/src/migration.rs @@ -51,7 +51,7 @@ pub mod v1 { } /// A migration utility to update the storage version from v0 to v1 for the pallet. - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let current_version = Pallet::::current_storage_version(); diff --git a/substrate/frame/node-authorization/src/weights.rs b/substrate/frame/node-authorization/src/weights.rs index a4529c845c7c0..881eeaf7a4c09 100644 --- a/substrate/frame/node-authorization/src/weights.rs +++ b/substrate/frame/node-authorization/src/weights.rs @@ -22,7 +22,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; pub trait WeightInfo { fn add_well_known_node() -> Weight; diff --git a/substrate/frame/nomination-pools/src/tests.rs b/substrate/frame/nomination-pools/src/tests.rs index 47f48ba98b7fd..13298fa64f54c 100644 --- a/substrate/frame/nomination-pools/src/tests.rs +++ b/substrate/frame/nomination-pools/src/tests.rs @@ -23,7 +23,7 @@ use sp_runtime::{bounded_btree_map, traits::Dispatchable, FixedU128}; macro_rules! unbonding_pools_with_era { ($($k:expr => $v:expr),* $(,)?) => {{ - use sp_std::iter::{Iterator, IntoIterator}; + use ::core::iter::{Iterator, IntoIterator}; let not_bounded: BTreeMap<_, _> = Iterator::collect(IntoIterator::into_iter([$(($k, $v),)*])); BoundedBTreeMap::, TotalUnbondingPools>::try_from(not_bounded).unwrap() }}; diff --git a/substrate/frame/referenda/src/types.rs b/substrate/frame/referenda/src/types.rs index 8d6a13ef27c98..0a8fb4ff8200d 100644 --- a/substrate/frame/referenda/src/types.rs +++ b/substrate/frame/referenda/src/types.rs @@ -19,6 +19,7 @@ use super::*; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; +use core::fmt::Debug; use frame_support::{ traits::{schedule::v3::Anon, Bounded}, Parameter, @@ -26,7 +27,6 @@ use frame_support::{ use scale_info::TypeInfo; use sp_arithmetic::{Rounding::*, SignedRounding::*}; use sp_runtime::{FixedI64, PerThing, RuntimeDebug}; -use sp_std::fmt::Debug; pub type BalanceOf = <>::Currency as Currency<::AccountId>>::Balance; diff --git a/substrate/frame/safe-mode/src/lib.rs b/substrate/frame/safe-mode/src/lib.rs index 325d751e17f61..2bf2ebee0a4ac 100644 --- a/substrate/frame/safe-mode/src/lib.rs +++ b/substrate/frame/safe-mode/src/lib.rs @@ -79,6 +79,7 @@ pub mod mock; mod tests; pub mod weights; +use core::convert::TryInto; use frame_support::{ defensive_assert, pallet_prelude::*, @@ -96,7 +97,6 @@ use frame_support::{ use frame_system::pallet_prelude::*; use sp_arithmetic::traits::Zero; use sp_runtime::traits::Saturating; -use sp_std::{convert::TryInto, prelude::*}; pub use pallet::*; pub use weights::*; diff --git a/substrate/frame/salary/src/lib.rs b/substrate/frame/salary/src/lib.rs index 18e5c624218c5..f83a75dd97dc8 100644 --- a/substrate/frame/salary/src/lib.rs +++ b/substrate/frame/salary/src/lib.rs @@ -21,10 +21,10 @@ #![recursion_limit = "128"] use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use scale_info::TypeInfo; use sp_arithmetic::traits::{Saturating, Zero}; use sp_runtime::{Perbill, RuntimeDebug}; -use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ defensive, diff --git a/substrate/frame/salary/src/tests/unit.rs b/substrate/frame/salary/src/tests/unit.rs index 07ef5ce63d5b9..b3fd00ec76b9b 100644 --- a/substrate/frame/salary/src/tests/unit.rs +++ b/substrate/frame/salary/src/tests/unit.rs @@ -19,6 +19,7 @@ use std::collections::BTreeMap; +use core::cell::RefCell; use frame_support::{ assert_noop, assert_ok, derive_impl, pallet_prelude::Weight, @@ -26,7 +27,6 @@ use frame_support::{ traits::{tokens::ConvertRank, ConstU64}, }; use sp_runtime::{traits::Identity, BuildStorage, DispatchResult}; -use sp_std::cell::RefCell; use crate as pallet_salary; use crate::*; diff --git a/substrate/frame/sassafras/src/mock.rs b/substrate/frame/sassafras/src/mock.rs index 82ea2fe1ef29e..5e5909fcb0d6e 100644 --- a/substrate/frame/sassafras/src/mock.rs +++ b/substrate/frame/sassafras/src/mock.rs @@ -99,7 +99,7 @@ pub fn new_test_ext_with_pairs( pallet_sassafras::GenesisConfig:: { authorities: authorities.clone(), epoch_config: TEST_EPOCH_CONFIGURATION, - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } .assimilate_storage(&mut storage) .unwrap(); diff --git a/substrate/frame/scheduler/src/migration.rs b/substrate/frame/scheduler/src/migration.rs index 76e2e04b49cc6..c2e956035a767 100644 --- a/substrate/frame/scheduler/src/migration.rs +++ b/substrate/frame/scheduler/src/migration.rs @@ -81,7 +81,7 @@ pub mod v3 { StorageMap, Twox64Concat, Vec, TaskAddress>>; /// Migrate the scheduler pallet from V3 to V4. - pub struct MigrateToV4(sp_std::marker::PhantomData); + pub struct MigrateToV4(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV4 { #[cfg(feature = "try-runtime")] @@ -194,7 +194,7 @@ pub mod v4 { /// /// This should be run on a scheduler that does not have /// since it piles up `None`-only agendas. This does not modify the pallet version. - pub struct CleanupAgendas(sp_std::marker::PhantomData); + pub struct CleanupAgendas(core::marker::PhantomData); impl OnRuntimeUpgrade for CleanupAgendas { #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/session/src/migrations/v1.rs b/substrate/frame/session/src/migrations/v1.rs index 394a1f4a5227c..b6838099837a0 100644 --- a/substrate/frame/session/src/migrations/v1.rs +++ b/substrate/frame/session/src/migrations/v1.rs @@ -15,8 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::str; use sp_io::hashing::twox_128; -use sp_std::str; use frame_support::{ storage::{generator::StorageValue, StoragePrefixedMap}, diff --git a/substrate/frame/society/src/migrations.rs b/substrate/frame/society/src/migrations.rs index a995c9d7be7f2..dafb1e0b9e5e9 100644 --- a/substrate/frame/society/src/migrations.rs +++ b/substrate/frame/society/src/migrations.rs @@ -29,7 +29,7 @@ const TARGET: &'static str = "runtime::society::migration"; /// This migration moves all the state to v2 of Society. pub struct VersionUncheckedMigrateToV2, I: 'static, PastPayouts>( - sp_std::marker::PhantomData<(T, I, PastPayouts)>, + core::marker::PhantomData<(T, I, PastPayouts)>, ); impl< diff --git a/substrate/frame/society/src/weights.rs b/substrate/frame/society/src/weights.rs index 7c59aed8449a2..c32c2383ac993 100644 --- a/substrate/frame/society/src/weights.rs +++ b/substrate/frame/society/src/weights.rs @@ -41,7 +41,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_society. pub trait WeightInfo { diff --git a/substrate/frame/staking/src/election_size_tracker.rs b/substrate/frame/staking/src/election_size_tracker.rs index 283ae0140ee68..36e7fa48fda5a 100644 --- a/substrate/frame/staking/src/election_size_tracker.rs +++ b/substrate/frame/staking/src/election_size_tracker.rs @@ -84,7 +84,7 @@ use frame_election_provider_support::{ pub struct StaticTracker { pub size: usize, pub counter: usize, - _marker: sp_std::marker::PhantomData, + _marker: core::marker::PhantomData, } impl Default for StaticTracker { diff --git a/substrate/frame/staking/src/migrations.rs b/substrate/frame/staking/src/migrations.rs index 92af4fdba5fd9..98984be9920d7 100644 --- a/substrate/frame/staking/src/migrations.rs +++ b/substrate/frame/staking/src/migrations.rs @@ -64,7 +64,7 @@ type StorageVersion = StorageValue, ObsoleteReleases, Value pub mod v14 { use super::*; - pub struct MigrateToV14(sp_std::marker::PhantomData); + pub struct MigrateToV14(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV14 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::current_storage_version(); @@ -95,7 +95,7 @@ pub mod v14 { pub mod v13 { use super::*; - pub struct MigrateToV13(sp_std::marker::PhantomData); + pub struct MigrateToV13(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV13 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { @@ -151,7 +151,7 @@ pub mod v12 { /// /// We will be depending on the configurable value of `T::HistoryDepth` post /// this release. - pub struct MigrateToV12(sp_std::marker::PhantomData); + pub struct MigrateToV12(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV12 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { @@ -205,7 +205,7 @@ pub mod v11 { #[cfg(feature = "try-runtime")] use sp_io::hashing::twox_128; - pub struct MigrateToV11(sp_std::marker::PhantomData<(T, P, N)>); + pub struct MigrateToV11(core::marker::PhantomData<(T, P, N)>); impl> OnRuntimeUpgrade for MigrateToV11 { @@ -301,7 +301,7 @@ pub mod v10 { /// That means we might slash someone a bit too early, but we will definitely /// won't forget to slash them. The cap of 512 is somewhat randomly taken to /// prevent us from iterating over an arbitrary large number of keys `on_runtime_upgrade`. - pub struct MigrateToV10(sp_std::marker::PhantomData); + pub struct MigrateToV10(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV10 { fn on_runtime_upgrade() -> frame_support::weights::Weight { if StorageVersion::::get() == ObsoleteReleases::V9_0_0 { diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/call.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/call.rs index ce2aa0942794d..b0041ccc07541 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -178,7 +178,7 @@ pub fn expand_outer_dispatch( type PostInfo = #scrate::dispatch::PostDispatchInfo; fn dispatch(self, origin: RuntimeOrigin) -> #scrate::dispatch::DispatchResultWithPostInfo { if !::filter_call(&origin, &self) { - return #scrate::__private::sp_std::result::Result::Err( + return ::core::result::Result::Err( #system_path::Error::<#runtime>::CallFiltered.into() ); } diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs index df69c19a4b617..80b242ccbe493 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/outer_enums.rs @@ -134,7 +134,6 @@ pub fn expand_outer_enum( enum_ty, )); enum_conversions.extend(expand_enum_conversion( - scrate, pallet_decl, &pallet_enum, &enum_name_ident, @@ -220,7 +219,6 @@ fn expand_enum_variant( } fn expand_enum_conversion( - scrate: &TokenStream, pallet: &Pallet, pallet_enum: &TokenStream, enum_name_ident: &Ident, @@ -247,7 +245,7 @@ fn expand_enum_conversion( impl TryInto<#pallet_enum> for #enum_name_ident { type Error = (); - fn try_into(self) -> #scrate::__private::sp_std::result::Result<#pallet_enum, Self::Error> { + fn try_into(self) -> ::core::result::Result<#pallet_enum, Self::Error> { match self { Self::#variant_name(evt) => Ok(evt), _ => Err(()), diff --git a/substrate/frame/support/procedural/src/pallet/expand/call.rs b/substrate/frame/support/procedural/src/pallet/expand/call.rs index 90974619e8e35..f43faba1ee0c8 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/call.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/call.rs @@ -304,7 +304,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] #[codec(skip)] __Ignore( - #frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen,)>, + ::core::marker::PhantomData<(#type_use_gen,)>, #frame_support::Never, ), #( diff --git a/substrate/frame/support/procedural/src/pallet/expand/event.rs b/substrate/frame/support/procedural/src/pallet/expand/event.rs index 2713f45fc3d54..655fc5507d265 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/event.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/event.rs @@ -87,7 +87,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] #[codec(skip)] __Ignore( - #frame_support::__private::sp_std::marker::PhantomData<(#event_use_gen)>, + ::core::marker::PhantomData<(#event_use_gen)>, #frame_support::Never, ) ); diff --git a/substrate/frame/support/procedural/src/pallet/parse/composite.rs b/substrate/frame/support/procedural/src/pallet/parse/composite.rs index a744756234ede..c3ac74846bf7c 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/composite.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/composite.rs @@ -171,7 +171,7 @@ impl CompositeDef { #[doc(hidden)] #[codec(skip)] __Ignore( - #scrate::__private::sp_std::marker::PhantomData, + ::core::marker::PhantomData, ) }); } diff --git a/substrate/frame/support/procedural/src/storage_alias.rs b/substrate/frame/support/procedural/src/storage_alias.rs index c0b4089a2748f..06f62768ff80f 100644 --- a/substrate/frame/support/procedural/src/storage_alias.rs +++ b/substrate/frame/support/procedural/src/storage_alias.rs @@ -623,7 +623,7 @@ fn generate_storage_instance( quote! { #visibility struct #counter_name< #impl_generics >( - #crate_::__private::sp_std::marker::PhantomData<(#type_generics)> + ::core::marker::PhantomData<(#type_generics)> ) #where_clause; impl<#impl_generics> #crate_::traits::StorageInstance @@ -653,7 +653,7 @@ fn generate_storage_instance( let code = quote! { #[allow(non_camel_case_types)] #visibility struct #name< #impl_generics >( - #crate_::__private::sp_std::marker::PhantomData<(#type_generics)> + ::core::marker::PhantomData<(#type_generics)> ) #where_clause; impl<#impl_generics> #crate_::traits::StorageInstance diff --git a/substrate/frame/support/src/tests/mod.rs b/substrate/frame/support/src/tests/mod.rs index c6a0b6cde7737..c63bfb181c3ff 100644 --- a/substrate/frame/support/src/tests/mod.rs +++ b/substrate/frame/support/src/tests/mod.rs @@ -171,7 +171,7 @@ pub mod frame_system { pub data: Vec<(u32, u64)>, pub test_config: Vec<(u32, u32, u64)>, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } impl Default for GenesisConfig { diff --git a/substrate/frame/support/src/traits/dispatch.rs b/substrate/frame/support/src/traits/dispatch.rs index facc35a77ae09..de50ce7a26c21 100644 --- a/substrate/frame/support/src/traits/dispatch.rs +++ b/substrate/frame/support/src/traits/dispatch.rs @@ -19,11 +19,11 @@ use crate::dispatch::{DispatchResultWithPostInfo, Parameter, RawOrigin}; use codec::MaxEncodedLen; +use core::{cmp::Ordering, marker::PhantomData}; use sp_runtime::{ traits::{BadOrigin, Get, Member, Morph, TryMorph}, Either, }; -use sp_std::{cmp::Ordering, marker::PhantomData}; use super::misc; @@ -85,7 +85,7 @@ pub trait EnsureOrigin { /// ```rust /// # use frame_support::traits::{EnsureOriginEqualOrHigherPrivilege, PrivilegeCmp, EnsureOrigin as _}; /// # use sp_runtime::traits::{parameter_types, Get}; -/// # use sp_std::cmp::Ordering; +/// # use core::cmp::Ordering; /// /// #[derive(Eq, PartialEq, Debug)] /// pub enum Origin { @@ -124,7 +124,7 @@ pub trait EnsureOrigin { /// assert!(EnsureOrigin::ensure_origin(Origin::NormalUser).is_err()); /// ``` pub struct EnsureOriginEqualOrHigherPrivilege( - sp_std::marker::PhantomData<(Origin, PrivilegeCmp)>, + core::marker::PhantomData<(Origin, PrivilegeCmp)>, ); impl EnsureOrigin @@ -218,7 +218,7 @@ macro_rules! impl_ensure_origin_with_arg_ignoring_arg { } /// [`EnsureOrigin`] implementation that always fails. -pub struct NeverEnsureOrigin(sp_std::marker::PhantomData); +pub struct NeverEnsureOrigin(core::marker::PhantomData); impl EnsureOrigin for NeverEnsureOrigin { type Success = Success; fn try_origin(o: OO) -> Result { @@ -235,7 +235,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { {} } -pub struct AsEnsureOriginWithArg(sp_std::marker::PhantomData); +pub struct AsEnsureOriginWithArg(core::marker::PhantomData); impl> EnsureOriginWithArg for AsEnsureOriginWithArg { @@ -353,7 +353,7 @@ impl< /// Origin check will pass if `L` or `R` origin check passes. `L` is tested first. /// /// Successful origin is derived from the left side. -pub struct EitherOfDiverse(sp_std::marker::PhantomData<(L, R)>); +pub struct EitherOfDiverse(core::marker::PhantomData<(L, R)>); impl, R: EnsureOrigin> EnsureOrigin for EitherOfDiverse { @@ -402,7 +402,7 @@ pub type EnsureOneOf = EitherOfDiverse; /// Origin check will pass if `L` or `R` origin check passes. `L` is tested first. /// /// Successful origin is derived from the left side. -pub struct EitherOf(sp_std::marker::PhantomData<(L, R)>); +pub struct EitherOf(core::marker::PhantomData<(L, R)>); impl< OuterOrigin, L: EnsureOrigin, diff --git a/substrate/frame/support/src/traits/error.rs b/substrate/frame/support/src/traits/error.rs index 0f30e266da2df..7b577fe9995a4 100644 --- a/substrate/frame/support/src/traits/error.rs +++ b/substrate/frame/support/src/traits/error.rs @@ -17,7 +17,7 @@ //! Traits for describing and constraining pallet error types. use codec::{Compact, Decode, Encode}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Trait indicating that the implementing type is going to be included as a field in a variant of /// the `#[pallet::error]` enum type. diff --git a/substrate/frame/support/src/traits/stored_map.rs b/substrate/frame/support/src/traits/stored_map.rs index cbe70f2932349..15df2ef0af55d 100644 --- a/substrate/frame/support/src/traits/stored_map.rs +++ b/substrate/frame/support/src/traits/stored_map.rs @@ -81,7 +81,7 @@ pub trait StoredMap { /// be the default value), or where the account is being removed or reset back to the default value /// where previously it did exist (though may have been in a default state). This works well with /// system module's `CallOnCreatedAccount` and `CallKillAccount`. -pub struct StorageMapShim(sp_std::marker::PhantomData<(S, K, T)>); +pub struct StorageMapShim(core::marker::PhantomData<(S, K, T)>); impl, K: FullCodec, T: FullCodec + Default> StoredMap for StorageMapShim { diff --git a/substrate/frame/support/src/traits/tokens/currency.rs b/substrate/frame/support/src/traits/tokens/currency.rs index 0030e1261dac1..8b773115011de 100644 --- a/substrate/frame/support/src/traits/tokens/currency.rs +++ b/substrate/frame/support/src/traits/tokens/currency.rs @@ -211,7 +211,7 @@ pub trait Currency { /// A non-const `Get` implementation parameterised by a `Currency` impl which provides the result /// of `total_issuance`. -pub struct TotalIssuanceOf, A>(sp_std::marker::PhantomData<(C, A)>); +pub struct TotalIssuanceOf, A>(core::marker::PhantomData<(C, A)>); impl, A> Get for TotalIssuanceOf { fn get() -> C::Balance { C::total_issuance() @@ -220,7 +220,7 @@ impl, A> Get for TotalIssuanceOf { /// A non-const `Get` implementation parameterised by a `Currency` impl which provides the result /// of `active_issuance`. -pub struct ActiveIssuanceOf, A>(sp_std::marker::PhantomData<(C, A)>); +pub struct ActiveIssuanceOf, A>(core::marker::PhantomData<(C, A)>); impl, A> Get for ActiveIssuanceOf { fn get() -> C::Balance { C::active_issuance() diff --git a/substrate/frame/support/src/traits/tokens/imbalance.rs b/substrate/frame/support/src/traits/tokens/imbalance.rs index 9dd8531324dc9..8eb9b355a4cf6 100644 --- a/substrate/frame/support/src/traits/tokens/imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/imbalance.rs @@ -19,8 +19,8 @@ //! with unbalanced operations. use crate::traits::misc::{SameOrOther, TryDrop}; +use core::ops::Div; use sp_runtime::traits::Saturating; -use sp_std::ops::Div; mod on_unbalanced; mod signed_imbalance; diff --git a/substrate/frame/tips/src/migrations/v4.rs b/substrate/frame/tips/src/migrations/v4.rs index 2404c6de1a16b..8b0e65c58dbde 100644 --- a/substrate/frame/tips/src/migrations/v4.rs +++ b/substrate/frame/tips/src/migrations/v4.rs @@ -15,8 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::str; use sp_io::hashing::twox_128; -use sp_std::str; use super::super::LOG_TARGET; use frame_support::{ diff --git a/substrate/frame/transaction-payment/src/payment.rs b/substrate/frame/transaction-payment/src/payment.rs index 22b0ac7c74240..886683f2e0b88 100644 --- a/substrate/frame/transaction-payment/src/payment.rs +++ b/substrate/frame/transaction-payment/src/payment.rs @@ -18,11 +18,11 @@ /// ! Traits and default implementation for paying transaction fees. use crate::Config; +use core::marker::PhantomData; use sp_runtime::{ traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero}, transaction_validity::InvalidTransaction, }; -use sp_std::marker::PhantomData; use frame_support::{ traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReasons}, diff --git a/substrate/frame/uniques/src/migration.rs b/substrate/frame/uniques/src/migration.rs index 6b2bbf375e754..ba0855a6bb657 100644 --- a/substrate/frame/uniques/src/migration.rs +++ b/substrate/frame/uniques/src/migration.rs @@ -17,8 +17,8 @@ //! Various pieces of common functionality. use super::*; +use core::marker::PhantomData; use frame_support::traits::{Get, OnRuntimeUpgrade}; -use sp_std::marker::PhantomData; mod v1 { use super::*; diff --git a/substrate/primitives/api/proc-macro/src/impl_runtime_apis.rs b/substrate/primitives/api/proc-macro/src/impl_runtime_apis.rs index 79378968437d9..b7e5600a017a9 100644 --- a/substrate/primitives/api/proc-macro/src/impl_runtime_apis.rs +++ b/substrate/primitives/api/proc-macro/src/impl_runtime_apis.rs @@ -243,7 +243,7 @@ fn generate_wasm_interface(impls: &[ItemImpl]) -> Result { &[0u8; 0] } else { unsafe { - #c::slice::from_raw_parts(input_data, input_len) + ::core::slice::from_raw_parts(input_data, input_len) } }; @@ -345,7 +345,7 @@ fn generate_runtime_api_base_structures() -> Result { &self, backend: &B, parent_hash: Block::Hash, - ) -> core::result::Result< + ) -> ::core::result::Result< #crate_::StorageChanges, String > where Self: Sized { diff --git a/substrate/primitives/arithmetic/src/helpers_128bit.rs b/substrate/primitives/arithmetic/src/helpers_128bit.rs index 4e234d4026c9a..cbbad58443f92 100644 --- a/substrate/primitives/arithmetic/src/helpers_128bit.rs +++ b/substrate/primitives/arithmetic/src/helpers_128bit.rs @@ -22,7 +22,7 @@ //! multiplication implementation provided there. use crate::{biguint, Rounding}; -use sp_std::cmp::{max, min}; +use core::cmp::{max, min}; /// Helper gcd function used in Rational128 implementation. pub fn gcd(a: u128, b: u128) -> u128 { diff --git a/substrate/primitives/arithmetic/src/traits.rs b/substrate/primitives/arithmetic/src/traits.rs index 6fcc8248539ca..66ec19c1b573a 100644 --- a/substrate/primitives/arithmetic/src/traits.rs +++ b/substrate/primitives/arithmetic/src/traits.rs @@ -18,6 +18,9 @@ //! Primitive traits for the runtime arithmetic. use codec::HasCompact; +use core::ops::{ + Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign, +}; pub use ensure::{ ensure_pow, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, EnsureDivAssign, EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, EnsureOp, @@ -28,9 +31,6 @@ pub use num_traits::{ checked_pow, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub, One, Signed, Unsigned, Zero, }; -use sp_std::ops::{ - Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign, -}; use crate::MultiplyRational; @@ -262,7 +262,7 @@ pub trait Saturating { Self: One, { let mut o = Self::one(); - sp_std::mem::swap(&mut o, self); + core::mem::swap(&mut o, self); *self = o.saturating_add(One::one()); } @@ -272,7 +272,7 @@ pub trait Saturating { Self: One, { let mut o = Self::one(); - sp_std::mem::swap(&mut o, self); + core::mem::swap(&mut o, self); *self = o.saturating_sub(One::one()); } @@ -282,7 +282,7 @@ pub trait Saturating { Self: One, { let mut o = Self::one(); - sp_std::mem::swap(&mut o, self); + core::mem::swap(&mut o, self); *self = o.saturating_add(amount); } @@ -292,7 +292,7 @@ pub trait Saturating { Self: One, { let mut o = Self::one(); - sp_std::mem::swap(&mut o, self); + core::mem::swap(&mut o, self); *self = o.saturating_sub(amount); } } @@ -949,7 +949,7 @@ mod ensure { } } - impl sp_std::ops::Mul for Signum { + impl core::ops::Mul for Signum { type Output = Self; fn mul(self, rhs: Self) -> Self { diff --git a/substrate/primitives/consensus/aura/src/inherents.rs b/substrate/primitives/consensus/aura/src/inherents.rs index 1ef25feb0ad62..733081dd790a1 100644 --- a/substrate/primitives/consensus/aura/src/inherents.rs +++ b/substrate/primitives/consensus/aura/src/inherents.rs @@ -69,7 +69,7 @@ impl InherentDataProvider { } #[cfg(feature = "std")] -impl sp_std::ops::Deref for InherentDataProvider { +impl core::ops::Deref for InherentDataProvider { type Target = InherentType; fn deref(&self) -> &Self::Target { diff --git a/substrate/primitives/consensus/babe/src/inherents.rs b/substrate/primitives/consensus/babe/src/inherents.rs index b01bd1c9221f2..909769f3031be 100644 --- a/substrate/primitives/consensus/babe/src/inherents.rs +++ b/substrate/primitives/consensus/babe/src/inherents.rs @@ -17,8 +17,8 @@ //! Inherents for BABE +use core::result::Result; use sp_inherents::{Error, InherentData, InherentIdentifier}; -use sp_std::result::Result; /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; @@ -75,7 +75,7 @@ impl InherentDataProvider { } #[cfg(feature = "std")] -impl sp_std::ops::Deref for InherentDataProvider { +impl core::ops::Deref for InherentDataProvider { type Target = InherentType; fn deref(&self) -> &Self::Target { diff --git a/substrate/primitives/consensus/slots/src/lib.rs b/substrate/primitives/consensus/slots/src/lib.rs index 23cb7f7365ada..eb3b3d3a449f2 100644 --- a/substrate/primitives/consensus/slots/src/lib.rs +++ b/substrate/primitives/consensus/slots/src/lib.rs @@ -155,9 +155,9 @@ impl SlotDuration { #[cfg(feature = "std")] impl SlotDuration { - /// Returns `self` as [`sp_std::time::Duration`]. - pub const fn as_duration(&self) -> sp_std::time::Duration { - sp_std::time::Duration::from_millis(self.0) + /// Returns `self` as [`core::time::Duration`]. + pub const fn as_duration(&self) -> core::time::Duration { + core::time::Duration::from_millis(self.0) } } diff --git a/substrate/primitives/core/src/testing.rs b/substrate/primitives/core/src/testing.rs index 947dcc387fc79..c26e23d442f1f 100644 --- a/substrate/primitives/core/src/testing.rs +++ b/substrate/primitives/core/src/testing.rs @@ -89,7 +89,7 @@ macro_rules! wasm_export_functions { &[0u8; 0] } else { unsafe { - $crate::sp_std::slice::from_raw_parts(input_data, input_len) + ::core::slice::from_raw_parts(input_data, input_len) } }; @@ -117,7 +117,7 @@ macro_rules! wasm_export_functions { &[0u8; 0] } else { unsafe { - $crate::sp_std::slice::from_raw_parts(input_data, input_len) + ::core::slice::from_raw_parts(input_data, input_len) } }; diff --git a/substrate/primitives/runtime-interface/src/util.rs b/substrate/primitives/runtime-interface/src/util.rs index 8db32271a0e7e..86c8e4b50e293 100644 --- a/substrate/primitives/runtime-interface/src/util.rs +++ b/substrate/primitives/runtime-interface/src/util.rs @@ -21,7 +21,7 @@ pub fn pack_ptr_and_len(ptr: u32, len: u32) -> u64 { // The static assertions from above are changed into a runtime check. #[cfg(all(not(feature = "std"), feature = "disable_target_static_assertions"))] - assert_eq!(4, sp_std::mem::size_of::()); + assert_eq!(4, core::mem::size_of::()); (u64::from(len) << 32) | u64::from(ptr) } @@ -34,7 +34,7 @@ pub fn pack_ptr_and_len(ptr: u32, len: u32) -> u64 { pub fn unpack_ptr_and_len(val: u64) -> (u32, u32) { // The static assertions from above are changed into a runtime check. #[cfg(all(not(feature = "std"), feature = "disable_target_static_assertions"))] - assert_eq!(4, sp_std::mem::size_of::()); + assert_eq!(4, core::mem::size_of::()); let ptr = (val & (!0u32 as u64)) as u32; let len = (val >> 32) as u32; diff --git a/substrate/primitives/runtime-interface/src/wasm.rs b/substrate/primitives/runtime-interface/src/wasm.rs index 91205addf21a0..10bb50c640398 100644 --- a/substrate/primitives/runtime-interface/src/wasm.rs +++ b/substrate/primitives/runtime-interface/src/wasm.rs @@ -19,7 +19,7 @@ use crate::RIType; -use sp_std::cell::Cell; +use core::cell::Cell; /// Something that can be created from a ffi value. /// diff --git a/substrate/primitives/runtime/src/generic/header.rs b/substrate/primitives/runtime/src/generic/header.rs index 0eeef363a06dc..d78aa5c8d3c29 100644 --- a/substrate/primitives/runtime/src/generic/header.rs +++ b/substrate/primitives/runtime/src/generic/header.rs @@ -133,7 +133,7 @@ where impl Header where Number: Member - + sp_std::hash::Hash + + core::hash::Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned diff --git a/substrate/primitives/runtime/src/offchain/storage_lock.rs b/substrate/primitives/runtime/src/offchain/storage_lock.rs index a2da48721e759..56d0eeae527cf 100644 --- a/substrate/primitives/runtime/src/offchain/storage_lock.rs +++ b/substrate/primitives/runtime/src/offchain/storage_lock.rs @@ -66,9 +66,9 @@ use crate::{ traits::BlockNumberProvider, }; use codec::{Codec, Decode, Encode}; +use core::fmt; use sp_core::offchain::{Duration, Timestamp}; use sp_io::offchain; -use sp_std::fmt; /// Default expiry duration for time based locks in milliseconds. const STORAGE_LOCK_DEFAULT_EXPIRY_DURATION: Duration = Duration::from_millis(20_000); diff --git a/substrate/primitives/state-machine/src/error.rs b/substrate/primitives/state-machine/src/error.rs index 4e8e02a26025c..cf8ca4425c119 100644 --- a/substrate/primitives/state-machine/src/error.rs +++ b/substrate/primitives/state-machine/src/error.rs @@ -16,7 +16,7 @@ // limitations under the License. /// State Machine Errors -use sp_std::fmt; +use core::fmt; /// State Machine Error bound. /// diff --git a/substrate/primitives/state-machine/src/in_memory_backend.rs b/substrate/primitives/state-machine/src/in_memory_backend.rs index ce551cec2a473..06fe6d4162a7f 100644 --- a/substrate/primitives/state-machine/src/in_memory_backend.rs +++ b/substrate/primitives/state-machine/src/in_memory_backend.rs @@ -79,7 +79,7 @@ where /// Apply the given transaction to this backend and set the root to the given value. pub fn apply_transaction(&mut self, root: H::Out, transaction: PrefixedMemoryDB) { - let mut storage = sp_std::mem::take(self).into_storage(); + let mut storage = core::mem::take(self).into_storage(); storage.consolidate(transaction); *self = TrieBackendBuilder::new(storage, root).build(); diff --git a/substrate/primitives/state-machine/src/stats.rs b/substrate/primitives/state-machine/src/stats.rs index 7c5510961a373..84ab7725660da 100644 --- a/substrate/primitives/state-machine/src/stats.rs +++ b/substrate/primitives/state-machine/src/stats.rs @@ -17,7 +17,7 @@ //! Usage statistics for state db -use sp_std::cell::RefCell; +use core::cell::RefCell; #[cfg(feature = "std")] use std::time::{Duration, Instant}; diff --git a/substrate/primitives/timestamp/src/lib.rs b/substrate/primitives/timestamp/src/lib.rs index d1bd2a3446e6b..a91ee16afe8e3 100644 --- a/substrate/primitives/timestamp/src/lib.rs +++ b/substrate/primitives/timestamp/src/lib.rs @@ -20,8 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; +use core::time::Duration; use sp_inherents::{InherentData, InherentIdentifier, IsFatalError}; -use sp_std::time::Duration; /// The identifier for the `timestamp` inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0"; @@ -69,7 +69,7 @@ impl Timestamp { } } -impl sp_std::ops::Deref for Timestamp { +impl core::ops::Deref for Timestamp { type Target = u64; fn deref(&self) -> &Self::Target { @@ -219,7 +219,7 @@ impl InherentDataProvider { } #[cfg(feature = "std")] -impl sp_std::ops::Deref for InherentDataProvider { +impl core::ops::Deref for InherentDataProvider { type Target = InherentType; fn deref(&self) -> &Self::Target { diff --git a/substrate/primitives/trie/src/node_header.rs b/substrate/primitives/trie/src/node_header.rs index c118ee07b8cbd..dc33e6bd61492 100644 --- a/substrate/primitives/trie/src/node_header.rs +++ b/substrate/primitives/trie/src/node_header.rs @@ -19,7 +19,7 @@ use crate::trie_constants; use codec::{Decode, Encode, Input, Output}; -use sp_std::iter::once; +use core::iter::once; /// A node header #[derive(Copy, Clone, PartialEq, Eq, sp_core::RuntimeDebug)] @@ -118,7 +118,7 @@ pub(crate) fn size_and_prefix_iterator( prefix_mask: usize, ) -> impl Iterator { let max_value = 255u8 >> prefix_mask; - let l1 = sp_std::cmp::min((max_value as usize).saturating_sub(1), size); + let l1 = core::cmp::min((max_value as usize).saturating_sub(1), size); let (first_byte, mut rem) = if size == l1 { (once(prefix + l1 as u8), 0) } else { @@ -138,7 +138,7 @@ pub(crate) fn size_and_prefix_iterator( None } }; - first_byte.chain(sp_std::iter::from_fn(next_bytes)) + first_byte.chain(core::iter::from_fn(next_bytes)) } /// Encodes size and prefix to a stream output. diff --git a/substrate/primitives/weights/src/lib.rs b/substrate/primitives/weights/src/lib.rs index ef431bddee265..aede9473535a3 100644 --- a/substrate/primitives/weights/src/lib.rs +++ b/substrate/primitives/weights/src/lib.rs @@ -235,7 +235,7 @@ where } /// Implementor of `WeightToFee` that maps one unit of weight to one unit of fee. -pub struct IdentityFee(sp_std::marker::PhantomData); +pub struct IdentityFee(core::marker::PhantomData); impl WeightToFee for IdentityFee where @@ -249,7 +249,7 @@ where } /// Implementor of [`WeightToFee`] such that it maps any unit of weight to a fixed fee. -pub struct FixedFee(sp_std::marker::PhantomData); +pub struct FixedFee(core::marker::PhantomData); impl WeightToFee for FixedFee where @@ -275,7 +275,7 @@ pub type NoFee = FixedFee<0, T>; /// // Results in a multiplier of 10 for each unit of weight (or length) /// type LengthToFee = ConstantMultiplier::>; /// ``` -pub struct ConstantMultiplier(sp_std::marker::PhantomData<(T, M)>); +pub struct ConstantMultiplier(core::marker::PhantomData<(T, M)>); impl WeightToFee for ConstantMultiplier where