Skip to content

Commit bc2e5e1

Browse files
authored
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 #2101
1 parent c552fb5 commit bc2e5e1

File tree

75 files changed

+125
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+125
-125
lines changed

substrate/frame/alliance/src/benchmarking.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
2020
#![cfg(feature = "runtime-benchmarks")]
2121

22-
use sp_runtime::traits::{Bounded, Hash, StaticLookup};
23-
use sp_std::{
22+
use core::{
2423
cmp,
2524
convert::{TryFrom, TryInto},
2625
mem::size_of,
27-
prelude::*,
2826
};
27+
use sp_runtime::traits::{Bounded, Hash, StaticLookup};
2928

3029
use frame_benchmarking::{account, impl_benchmark_test_suite, v2::*, BenchmarkError};
3130
use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};

substrate/frame/alliance/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
//! Test utilities
1919
20+
use core::convert::{TryFrom, TryInto};
2021
pub use sp_core::H256;
2122
use sp_runtime::traits::Hash;
2223
pub use sp_runtime::{
2324
traits::{BlakeTwo256, IdentifyAccount, Lazy, Verify},
2425
BuildStorage,
2526
};
26-
use sp_std::convert::{TryFrom, TryInto};
2727

2828
pub use frame_support::{
2929
assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types,

substrate/frame/asset-conversion/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
use super::*;
2121
use crate as pallet_asset_conversion;
22+
use core::default::Default;
2223
use frame_support::{
2324
construct_runtime, derive_impl,
2425
instances::{Instance1, Instance2},
@@ -39,7 +40,6 @@ use sp_runtime::{
3940
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup},
4041
BuildStorage,
4142
};
42-
use sp_std::default::Default;
4343

4444
type Block = frame_system::mocking::MockBlock<Test>;
4545

substrate/frame/asset-conversion/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
use super::*;
1919
use codec::{Decode, Encode, MaxEncodedLen};
20+
use core::marker::PhantomData;
2021
use scale_info::TypeInfo;
21-
use sp_std::marker::PhantomData;
2222

2323
/// Represents a swap path with associated asset amounts indicating how much of the asset needs to
2424
/// be deposited to get the following asset's amount withdrawn (this is inclusive of fees).

substrate/frame/assets/src/extra_mutator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<T: Config<I>, I: 'static> Drop for ExtraMutator<T, I> {
3838
}
3939
}
4040

41-
impl<T: Config<I>, I: 'static> sp_std::ops::Deref for ExtraMutator<T, I> {
41+
impl<T: Config<I>, I: 'static> core::ops::Deref for ExtraMutator<T, I> {
4242
type Target = T::Extra;
4343
fn deref(&self) -> &T::Extra {
4444
match self.pending {
@@ -48,7 +48,7 @@ impl<T: Config<I>, I: 'static> sp_std::ops::Deref for ExtraMutator<T, I> {
4848
}
4949
}
5050

51-
impl<T: Config<I>, I: 'static> sp_std::ops::DerefMut for ExtraMutator<T, I> {
51+
impl<T: Config<I>, I: 'static> core::ops::DerefMut for ExtraMutator<T, I> {
5252
fn deref_mut(&mut self) -> &mut T::Extra {
5353
if self.pending.is_none() {
5454
self.pending = Some(self.original.clone());
@@ -60,7 +60,7 @@ impl<T: Config<I>, I: 'static> sp_std::ops::DerefMut for ExtraMutator<T, I> {
6060
impl<T: Config<I>, I: 'static> ExtraMutator<T, I> {
6161
pub(super) fn maybe_new(
6262
id: T::AssetId,
63-
who: impl sp_std::borrow::Borrow<T::AccountId>,
63+
who: impl core::borrow::Borrow<T::AccountId>,
6464
) -> Option<ExtraMutator<T, I>> {
6565
if let Some(a) = Account::<T, I>::get(&id, who.borrow()) {
6666
Some(ExtraMutator::<T, I> {

substrate/frame/assets/src/migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub mod v1 {
6464
}
6565
}
6666

67-
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
67+
pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
6868
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
6969
fn on_runtime_upgrade() -> Weight {
7070
let current_version = Pallet::<T>::current_storage_version();

substrate/frame/assets/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
return None
124124
}
125125
if let ExistenceReason::DepositHeld(deposit) =
126-
sp_std::mem::replace(self, ExistenceReason::DepositRefunded)
126+
core::mem::replace(self, ExistenceReason::DepositRefunded)
127127
{
128128
Some(deposit)
129129
} else {
@@ -136,7 +136,7 @@ where
136136
return None
137137
}
138138
if let ExistenceReason::DepositFrom(depositor, deposit) =
139-
sp_std::mem::replace(self, ExistenceReason::DepositRefunded)
139+
core::mem::replace(self, ExistenceReason::DepositRefunded)
140140
{
141141
Some((depositor, deposit))
142142
} else {

substrate/frame/atomic-swap/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
mod tests;
4444

4545
use codec::{Decode, Encode};
46+
use core::{
47+
marker::PhantomData,
48+
ops::{Deref, DerefMut},
49+
};
4650
use frame_support::{
4751
dispatch::DispatchResult,
4852
pallet_prelude::MaxEncodedLen,
@@ -54,11 +58,6 @@ use frame_system::pallet_prelude::BlockNumberFor;
5458
use scale_info::TypeInfo;
5559
use sp_io::hashing::blake2_256;
5660
use sp_runtime::RuntimeDebug;
57-
use sp_std::{
58-
marker::PhantomData,
59-
ops::{Deref, DerefMut},
60-
prelude::*,
61-
};
6261

6362
/// Pending atomic swap operation.
6463
#[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)]

substrate/frame/aura/src/migrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
use frame_support::{pallet_prelude::*, traits::Get, weights::Weight};
2121

22-
struct __LastTimestamp<T>(sp_std::marker::PhantomData<T>);
22+
struct __LastTimestamp<T>(core::marker::PhantomData<T>);
2323
impl<T: RemoveLastTimestamp> frame_support::traits::StorageInstance for __LastTimestamp<T> {
2424
fn pallet_prefix() -> &'static str {
2525
T::PalletPrefix::get()

substrate/frame/babe/src/randomness.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use sp_runtime::traits::{Hash, One, Saturating};
5151
///
5252
/// Adversaries should not possess many block production slots towards the beginning or
5353
/// end of every epoch, but they possess some influence over when they possess more slots.
54-
pub struct RandomnessFromTwoEpochsAgo<T>(sp_std::marker::PhantomData<T>);
54+
pub struct RandomnessFromTwoEpochsAgo<T>(core::marker::PhantomData<T>);
5555

5656
/// Randomness usable by on-chain code that **does not depend** upon finality and takes
5757
/// action based upon on-chain commitments made during the previous epoch.
@@ -79,7 +79,7 @@ pub struct RandomnessFromTwoEpochsAgo<T>(sp_std::marker::PhantomData<T>);
7979
/// As an example usage, we determine parachain auctions ending times in Polkadot using
8080
/// `RandomnessFromOneEpochAgo` because it reduces bias from `ParentBlockRandomness` and
8181
/// does not require the extra finality delay of `RandomnessFromTwoEpochsAgo`.
82-
pub struct RandomnessFromOneEpochAgo<T>(sp_std::marker::PhantomData<T>);
82+
pub struct RandomnessFromOneEpochAgo<T>(core::marker::PhantomData<T>);
8383

8484
/// Randomness produced semi-freshly with each block, but inherits limitations of
8585
/// `RandomnessFromTwoEpochsAgo` from which it derives.
@@ -119,7 +119,7 @@ pub struct RandomnessFromOneEpochAgo<T>(sp_std::marker::PhantomData<T>);
119119
/// instead you are using this randomness externally, i.e. after block execution, then
120120
/// this randomness will be provided by the "current" block (this stems from the fact that
121121
/// we process VRF outputs on block execution finalization, i.e. `on_finalize`).
122-
pub struct ParentBlockRandomness<T>(sp_std::marker::PhantomData<T>);
122+
pub struct ParentBlockRandomness<T>(core::marker::PhantomData<T>);
123123

124124
/// Randomness produced semi-freshly with each block, but inherits limitations of
125125
/// `RandomnessFromTwoEpochsAgo` from which it derives.
@@ -128,7 +128,7 @@ pub struct ParentBlockRandomness<T>(sp_std::marker::PhantomData<T>);
128128
#[deprecated(note = "Should not be relied upon for correctness, \
129129
will not provide fresh randomness for the current block. \
130130
Please use `ParentBlockRandomness` instead.")]
131-
pub struct CurrentBlockRandomness<T>(sp_std::marker::PhantomData<T>);
131+
pub struct CurrentBlockRandomness<T>(core::marker::PhantomData<T>);
132132

133133
impl<T: Config> RandomnessT<T::Hash, BlockNumberFor<T>> for RandomnessFromTwoEpochsAgo<T> {
134134
fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor<T>) {

0 commit comments

Comments
 (0)