Remove useless imports (#11136)

Because `TryInto`/`TryFrom` are in prelude by default from edition 2021

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-04-04 03:44:29 +08:00
committed by GitHub
parent 98ed4afe45
commit 41c84b0b41
91 changed files with 81 additions and 176 deletions
@@ -127,7 +127,7 @@ fn expand_event_conversion(
Event::#variant_name(x)
}
}
impl #scrate::sp_std::convert::TryInto<#pallet_event> for Event {
impl TryInto<#pallet_event> for Event {
type Error = ();
fn try_into(self) -> #scrate::sp_std::result::Result<#pallet_event, Self::Error> {
@@ -230,7 +230,7 @@ pub fn expand_outer_origin(
}
}
impl #scrate::sp_std::convert::TryFrom<OriginCaller> for #system_path::Origin<#runtime> {
impl TryFrom<OriginCaller> for #system_path::Origin<#runtime> {
type Error = OriginCaller;
fn try_from(x: OriginCaller)
-> #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, OriginCaller>
@@ -359,7 +359,7 @@ fn expand_origin_pallet_conversions(
}
}
impl #scrate::sp_std::convert::TryFrom<OriginCaller> for #pallet_origin {
impl TryFrom<OriginCaller> for #pallet_origin {
type Error = OriginCaller;
fn try_from(
x: OriginCaller,
@@ -162,7 +162,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream {
#frame_support::sp_runtime::DispatchError::Module(#frame_support::sp_runtime::ModuleError {
index,
error: core::convert::TryInto::try_into(encoded).expect("encoded error is resized to be equal to the maximum encoded error size; qed"),
error: TryInto::try_into(encoded).expect("encoded error is resized to be equal to the maximum encoded error size; qed"),
message: Some(err.as_str()),
})
}
+1 -1
View File
@@ -152,7 +152,7 @@ macro_rules! decl_error {
$crate::sp_runtime::DispatchError::Module($crate::sp_runtime::ModuleError {
index,
error: core::convert::TryInto::try_into(error).expect("encoded error is resized to be equal to the maximum encoded error size; qed"),
error: TryInto::try_into(error).expect("encoded error is resized to be equal to the maximum encoded error size; qed"),
message: Some(err.as_str()),
})
}
-2
View File
@@ -127,13 +127,11 @@ impl TypeId for PalletId {
macro_rules! bounded_vec {
($ ($values:expr),* $(,)?) => {
{
use $crate::sp_std::convert::TryInto as _;
$crate::sp_std::vec![$($values),*].try_into().unwrap()
}
};
( $value:expr ; $repetition:expr ) => {
{
use $crate::sp_std::convert::TryInto as _;
$crate::sp_std::vec![$value ; $repetition].try_into().unwrap()
}
}
@@ -22,10 +22,7 @@ use crate::{
traits::{Get, TryCollect},
};
use codec::{Decode, Encode, MaxEncodedLen};
use sp_std::{
borrow::Borrow, collections::btree_map::BTreeMap, convert::TryFrom, marker::PhantomData,
ops::Deref,
};
use sp_std::{borrow::Borrow, collections::btree_map::BTreeMap, marker::PhantomData, ops::Deref};
/// A bounded map based on a B-Tree.
///
@@ -22,10 +22,7 @@ use crate::{
traits::{Get, TryCollect},
};
use codec::{Decode, Encode, MaxEncodedLen};
use sp_std::{
borrow::Borrow, collections::btree_set::BTreeSet, convert::TryFrom, marker::PhantomData,
ops::Deref,
};
use sp_std::{borrow::Borrow, collections::btree_set::BTreeSet, marker::PhantomData, ops::Deref};
/// A bounded set based on a B-Tree.
///
@@ -324,7 +321,6 @@ pub mod test {
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
use sp_std::convert::TryInto;
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedBTreeSet<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(Twox128, u32), BoundedBTreeSet<u32, ConstU32<7>>> }
@@ -27,7 +27,7 @@ use core::{
ops::{Deref, Index, IndexMut},
slice::SliceIndex,
};
use sp_std::{convert::TryFrom, marker::PhantomData, prelude::*};
use sp_std::{marker::PhantomData, prelude::*};
/// A weakly bounded vector.
///
@@ -320,7 +320,6 @@ pub mod test {
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
use sp_std::convert::TryInto;
crate::generate_storage_alias! { Prefix, Foo => Value<WeakBoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(Twox128, u32), WeakBoundedVec<u32, ConstU32<7>>> }