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
This commit is contained in:
Squirrel
2024-02-06 13:01:29 +00:00
committed by GitHub
parent c552fb5495
commit bc2e5e1fe2
75 changed files with 125 additions and 125 deletions
@@ -178,7 +178,7 @@ pub fn expand_outer_dispatch(
type PostInfo = #scrate::dispatch::PostDispatchInfo;
fn dispatch(self, origin: RuntimeOrigin) -> #scrate::dispatch::DispatchResultWithPostInfo {
if !<Self::RuntimeOrigin as #scrate::traits::OriginTrait>::filter_call(&origin, &self) {
return #scrate::__private::sp_std::result::Result::Err(
return ::core::result::Result::Err(
#system_path::Error::<#runtime>::CallFiltered.into()
);
}
@@ -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(()),
@@ -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,
),
#(
@@ -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,
)
);
@@ -171,7 +171,7 @@ impl CompositeDef {
#[doc(hidden)]
#[codec(skip)]
__Ignore(
#scrate::__private::sp_std::marker::PhantomData<I>,
::core::marker::PhantomData<I>,
)
});
}
@@ -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
+1 -1
View File
@@ -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<T>,
pub _config: core::marker::PhantomData<T>,
}
impl<T: Config> Default for GenesisConfig<T> {
@@ -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<OuterOrigin> {
/// ```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<OuterOrigin> {
/// assert!(EnsureOrigin::ensure_origin(Origin::NormalUser).is_err());
/// ```
pub struct EnsureOriginEqualOrHigherPrivilege<Origin, PrivilegeCmp>(
sp_std::marker::PhantomData<(Origin, PrivilegeCmp)>,
core::marker::PhantomData<(Origin, PrivilegeCmp)>,
);
impl<OuterOrigin, Origin, PrivilegeCmp> EnsureOrigin<OuterOrigin>
@@ -218,7 +218,7 @@ macro_rules! impl_ensure_origin_with_arg_ignoring_arg {
}
/// [`EnsureOrigin`] implementation that always fails.
pub struct NeverEnsureOrigin<Success>(sp_std::marker::PhantomData<Success>);
pub struct NeverEnsureOrigin<Success>(core::marker::PhantomData<Success>);
impl<OO, Success> EnsureOrigin<OO> for NeverEnsureOrigin<Success> {
type Success = Success;
fn try_origin(o: OO) -> Result<Success, OO> {
@@ -235,7 +235,7 @@ impl_ensure_origin_with_arg_ignoring_arg! {
{}
}
pub struct AsEnsureOriginWithArg<EO>(sp_std::marker::PhantomData<EO>);
pub struct AsEnsureOriginWithArg<EO>(core::marker::PhantomData<EO>);
impl<OuterOrigin, Argument, EO: EnsureOrigin<OuterOrigin>>
EnsureOriginWithArg<OuterOrigin, Argument> for AsEnsureOriginWithArg<EO>
{
@@ -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<L, R>(sp_std::marker::PhantomData<(L, R)>);
pub struct EitherOfDiverse<L, R>(core::marker::PhantomData<(L, R)>);
impl<OuterOrigin, L: EnsureOrigin<OuterOrigin>, R: EnsureOrigin<OuterOrigin>>
EnsureOrigin<OuterOrigin> for EitherOfDiverse<L, R>
{
@@ -402,7 +402,7 @@ pub type EnsureOneOf<L, R> = EitherOfDiverse<L, R>;
/// 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<L, R>(sp_std::marker::PhantomData<(L, R)>);
pub struct EitherOf<L, R>(core::marker::PhantomData<(L, R)>);
impl<
OuterOrigin,
L: EnsureOrigin<OuterOrigin>,
+1 -1
View File
@@ -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.
@@ -81,7 +81,7 @@ pub trait StoredMap<K, T: Default> {
/// 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<S, K, T>(sp_std::marker::PhantomData<(S, K, T)>);
pub struct StorageMapShim<S, K, T>(core::marker::PhantomData<(S, K, T)>);
impl<S: StorageMap<K, T, Query = T>, K: FullCodec, T: FullCodec + Default> StoredMap<K, T>
for StorageMapShim<S, K, T>
{
@@ -211,7 +211,7 @@ pub trait Currency<AccountId> {
/// A non-const `Get` implementation parameterised by a `Currency` impl which provides the result
/// of `total_issuance`.
pub struct TotalIssuanceOf<C: Currency<A>, A>(sp_std::marker::PhantomData<(C, A)>);
pub struct TotalIssuanceOf<C: Currency<A>, A>(core::marker::PhantomData<(C, A)>);
impl<C: Currency<A>, A> Get<C::Balance> for TotalIssuanceOf<C, A> {
fn get() -> C::Balance {
C::total_issuance()
@@ -220,7 +220,7 @@ impl<C: Currency<A>, A> Get<C::Balance> for TotalIssuanceOf<C, A> {
/// A non-const `Get` implementation parameterised by a `Currency` impl which provides the result
/// of `active_issuance`.
pub struct ActiveIssuanceOf<C: Currency<A>, A>(sp_std::marker::PhantomData<(C, A)>);
pub struct ActiveIssuanceOf<C: Currency<A>, A>(core::marker::PhantomData<(C, A)>);
impl<C: Currency<A>, A> Get<C::Balance> for ActiveIssuanceOf<C, A> {
fn get() -> C::Balance {
C::active_issuance()
@@ -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;