remove unnessisary use statements due to 2021 core prelude (#4183)

Some traits are already included in the 2021 prelude and so shouldn't be
needed to use explicitly:

use `convert::TryFrom`, `convert::TryInto`, and `iter::FromIterator` are
removed.

( https://doc.rust-lang.org/core/prelude/rust_2021/ )

No breaking changes or change of functionality, so I think no PR doc is
needed in this case.

(Motivation: Removes some references to `sp-std`)
This commit is contained in:
Squirrel
2024-04-28 16:29:21 +01:00
committed by GitHub
parent 73b9a8391f
commit 954150f3b5
56 changed files with 46 additions and 82 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ use frame_support::{traits::Get, weights::Weight};
use hash_db::Hasher;
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryFrom, marker::PhantomData, vec::Vec};
use sp_std::{marker::PhantomData, vec::Vec};
/// Bidirectional message bridge.
pub trait MessageBridge {
+1 -1
View File
@@ -49,7 +49,7 @@ use sp_runtime::{
traits::{Header as HeaderT, Zero},
SaturatedConversion,
};
use sp_std::{boxed::Box, convert::TryInto, prelude::*};
use sp_std::{boxed::Box, prelude::*};
mod call_ext;
#[cfg(test)]
+1 -1
View File
@@ -26,7 +26,7 @@ use sp_runtime::{
},
FixedPointOperand,
};
use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr, vec, vec::Vec};
use sp_std::{fmt::Debug, hash::Hash, str::FromStr, vec, vec::Vec};
/// Chain call, that is either SCALE-encoded, or decoded.
#[derive(Debug, Clone, PartialEq)]
+1 -1
View File
@@ -31,7 +31,7 @@ use sp_runtime::{
traits::{BadOrigin, Header as HeaderT, UniqueSaturatedInto},
RuntimeDebug,
};
use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec};
use sp_std::{fmt::Debug, ops::RangeInclusive, vec, vec::Vec};
pub use chain::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
@@ -46,7 +46,7 @@ use relay_utils::{
};
use sp_core::Pair;
use sp_runtime::traits::Zero;
use std::{convert::TryFrom, fmt::Debug, marker::PhantomData};
use std::{fmt::Debug, marker::PhantomData};
/// Substrate -> Substrate messages synchronization pipeline.
pub trait SubstrateMessageLane: 'static + Clone + Debug + Send + Sync {
@@ -32,7 +32,7 @@ use relay_substrate_client::{
use relay_utils::metrics::{MetricsParams, StandaloneMetric};
use sp_core::storage::StorageData;
use sp_runtime::{FixedPointNumber, FixedU128};
use std::{convert::TryFrom, fmt::Debug, marker::PhantomData};
use std::{fmt::Debug, marker::PhantomData};
/// Add relay accounts balance metrics.
pub async fn add_relay_balances_metrics<C: ChainWithBalances, BC: ChainWithMessages>(
@@ -45,7 +45,7 @@ use relay_substrate_client::{
};
use relay_utils::relay_loop::Client as RelayClient;
use sp_core::Pair;
use std::{convert::TryFrom, ops::RangeInclusive};
use std::ops::RangeInclusive;
/// Message receiving proof returned by the target Substrate node.
pub type SubstrateMessagesDeliveryProof<C> =
@@ -3,7 +3,7 @@
use snowbridge_core::{inbound::Log, ChannelId};
use sp_core::{RuntimeDebug, H160, H256};
use sp_std::{convert::TryFrom, prelude::*};
use sp_std::prelude::*;
use alloy_primitives::B256;
use alloy_sol_types::{sol, SolEvent};
@@ -50,7 +50,7 @@ use frame_system::ensure_signed;
use scale_info::TypeInfo;
use sp_core::{H160, H256};
use sp_runtime::traits::Zero;
use sp_std::{convert::TryFrom, vec};
use sp_std::vec;
use xcm::prelude::{
send_xcm, Instruction::SetTopic, Junction::*, Location, SendError as XcmpSendError, SendXcm,
Xcm, XcmContext, XcmHash,
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
use ssz_rs::{Bitvector, Deserialize};
pub fn decompress_sync_committee_bits<
@@ -7,7 +7,7 @@ use serde::{Deserialize, Deserializer};
// helper to deserialize arbitrary arrays like [T; N]
pub mod arrays {
use std::{convert::TryInto, marker::PhantomData};
use std::marker::PhantomData;
use serde::{
de::{SeqAccess, Visitor},
@@ -8,7 +8,7 @@ use rlp::RlpStream;
use scale_info::TypeInfo;
use sp_io::hashing::keccak_256;
use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
@@ -3,7 +3,7 @@
//! Helper types to work with Ethereum's Merkle Patricia Trie nodes
use ethereum_types::H256;
use sp_std::{convert::TryFrom, prelude::*};
use sp_std::prelude::*;
pub trait Node {
fn contains_hash(&self, hash: H256) -> bool;
@@ -3,7 +3,7 @@ name = "snowbridge-runtime-test-common"
description = "Snowbridge Runtime Tests"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
@@ -55,7 +55,7 @@ use sp_runtime::{
};
use sp_state_machine::StorageChanges;
use sp_timestamp::Timestamp;
use std::{convert::TryFrom, error::Error, time::Duration};
use std::{error::Error, time::Duration};
/// Parameters for instantiating a [`Collator`].
pub struct Params<BI, CIDP, RClient, Proposer, CS> {
@@ -48,7 +48,7 @@ use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member};
use sp_state_machine::Backend as _;
use std::{convert::TryFrom, sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration};
use crate::collator as collator_util;
@@ -67,7 +67,7 @@ use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member};
use sp_timestamp::Timestamp;
use std::{convert::TryFrom, sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration};
use crate::collator::{self as collator_util, SlotClaim};
+1 -1
View File
@@ -36,7 +36,7 @@ use polkadot_primitives::{
use codec::{Decode, DecodeAll, Encode};
use futures::{channel::oneshot, future::FutureExt, Future};
use std::{convert::TryFrom, fmt, marker::PhantomData, pin::Pin, sync::Arc};
use std::{fmt, marker::PhantomData, pin::Pin, sync::Arc};
#[cfg(test)]
mod tests;
@@ -2,7 +2,7 @@
name = "pallet-collective-content"
version = "0.6.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
description = "Managed content"
license = "Apache-2.0"
@@ -38,7 +38,7 @@ use polkadot_node_subsystem::{
use polkadot_node_subsystem_util::{self as util, Validator};
use polkadot_primitives::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex};
use sp_keystore::{Error as KeystoreError, KeystorePtr};
use std::{collections::HashMap, iter::FromIterator, time::Duration};
use std::{collections::HashMap, time::Duration};
use wasm_timer::{Delay, Instant};
mod metrics;
@@ -40,7 +40,7 @@ use sp_core::Pair as PairT;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
use std::{iter::FromIterator as _, sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration};
const TIMEOUT: Duration = Duration::from_millis(50);
macro_rules! launch {
@@ -16,7 +16,6 @@
use std::{
collections::{HashMap, HashSet},
convert::TryInto,
time::Duration,
};
@@ -20,9 +20,7 @@ use futures::{
use futures_timer::Delay;
use std::{
collections::{hash_map::Entry, HashMap, HashSet},
convert::TryInto,
future::Future,
iter::FromIterator,
time::{Duration, Instant},
};
use tokio_util::sync::CancellationToken;
@@ -55,7 +55,7 @@ use sp_application_crypto::{sr25519::Pair, AppCrypto, Pair as TraitPair};
use sp_authority_discovery::AuthorityPair;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{Keystore, KeystorePtr};
use std::{iter::FromIterator as _, sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration};
use util::reputation::add_reputation;
// Some deterministic genesis hash for protocol names
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use std::{collections::HashSet, convert::TryFrom};
use std::collections::HashSet;
pub use sc_network::ReputationChange;
pub use sc_network_types::PeerId;
-1
View File
@@ -26,7 +26,6 @@ use crate::{
VersionedLocation,
};
use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use core::convert::{TryFrom, TryInto};
use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
+1 -1
View File
@@ -17,7 +17,7 @@
//! XCM `Junctions`/`InteriorMultiLocation` datatype.
use super::{Junction, MultiLocation, NetworkId};
use core::{convert::TryFrom, mem, result};
use core::{mem, result};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
+1 -5
View File
@@ -29,11 +29,7 @@ use super::{
use crate::DoubleEncoded;
use alloc::{vec, vec::Vec};
use bounded_collections::{parameter_types, BoundedVec};
use core::{
convert::{TryFrom, TryInto},
fmt::Debug,
result,
};
use core::{fmt::Debug, result};
use derivative::Derivative;
use parity_scale_codec::{
self, decode_vec_with_len, Compact, Decode, Encode, Error as CodecError, Input as CodecInput,
+1 -4
View File
@@ -42,10 +42,7 @@ use crate::{
};
use alloc::{vec, vec::Vec};
use bounded_collections::{BoundedVec, ConstU32};
use core::{
cmp::Ordering,
convert::{TryFrom, TryInto},
};
use core::cmp::Ordering;
use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
+1 -5
View File
@@ -20,10 +20,7 @@ use super::{Junction, Junctions};
use crate::{
v2::MultiLocation as OldMultiLocation, v4::Location as NewMultiLocation, VersionedLocation,
};
use core::{
convert::{TryFrom, TryInto},
result,
};
use core::result;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
@@ -766,7 +763,6 @@ mod tests {
#[test]
fn conversion_from_other_types_works() {
use crate::v2;
use core::convert::TryInto;
fn takes_multilocation<Arg: Into<MultiLocation>>(_arg: Arg) {}
+1 -4
View File
@@ -34,10 +34,7 @@ use crate::v3::{
};
use alloc::{vec, vec::Vec};
use bounded_collections::{BoundedVec, ConstU32};
use core::{
cmp::Ordering,
convert::{TryFrom, TryInto},
};
use core::cmp::Ordering;
use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
-1
View File
@@ -23,7 +23,6 @@ use crate::{
VersionedLocation,
};
use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use core::convert::TryFrom;
use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
+1 -1
View File
@@ -18,7 +18,7 @@
use super::{Junction, Location, NetworkId};
use alloc::sync::Arc;
use core::{convert::TryFrom, mem, ops::Range, result};
use core::{mem, ops::Range, result};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
+1 -5
View File
@@ -18,10 +18,7 @@
use super::{traits::Reanchorable, Junction, Junctions};
use crate::{v3::MultiLocation as OldLocation, VersionedLocation};
use core::{
convert::{TryFrom, TryInto},
result,
};
use core::result;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
@@ -723,7 +720,6 @@ mod tests {
#[test]
fn conversion_from_other_types_works() {
use crate::v3;
use core::convert::TryInto;
fn takes_location<Arg: Into<Location>>(_arg: Arg) {}
+1 -5
View File
@@ -24,11 +24,7 @@ use super::v3::{
use crate::DoubleEncoded;
use alloc::{vec, vec::Vec};
use bounded_collections::{parameter_types, BoundedVec};
use core::{
convert::{TryFrom, TryInto},
fmt::Debug,
result,
};
use core::{fmt::Debug, result};
use derivative::Derivative;
use parity_scale_codec::{
self, decode_vec_with_len, Compact, Decode, Encode, Error as CodecError, Input as CodecInput,
@@ -15,7 +15,6 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::{test_utils::*, *};
use core::convert::TryInto;
use frame_support::{
assert_err,
traits::{ConstU32, ContainsPair, ProcessMessageError},
@@ -125,7 +125,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use std::{collections::HashSet, convert::TryInto, sync::Arc};
use std::{collections::HashSet, sync::Arc};
use jsonrpsee::{core::EmptyServerParams as EmptyParams, types::SubscriptionId, RpcModule};
use parity_scale_codec::{Decode, Encode};
@@ -18,7 +18,6 @@
use std::{
collections::{BTreeMap, HashMap},
iter::FromIterator,
marker::PhantomData,
pin::Pin,
sync::Arc,
+1 -1
View File
@@ -4,7 +4,7 @@ name = "sc-mixnet"
version = "0.4.0"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
readme = "README.md"
@@ -19,7 +19,6 @@
use futures::prelude::*;
use libp2p::core::upgrade::{InboundUpgrade, ProtocolName, UpgradeInfo};
use std::{
iter::FromIterator,
pin::Pin,
task::{Context, Poll},
vec,
+1 -1
View File
@@ -2,7 +2,7 @@
name = "polkadot-sdk-frame"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
homepage = "paritytech.github.io"
repository.workspace = true
+1 -5
View File
@@ -19,11 +19,7 @@
#![cfg(feature = "runtime-benchmarks")]
use core::{
cmp,
convert::{TryFrom, TryInto},
mem::size_of,
};
use core::{cmp, mem::size_of};
use sp_runtime::traits::{Bounded, Hash, StaticLookup};
use frame_benchmarking::{account, v2::*, BenchmarkError};
+1 -1
View File
@@ -101,7 +101,7 @@ use sp_runtime::{
traits::{Dispatchable, Saturating, StaticLookup, Zero},
DispatchError, RuntimeDebug,
};
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
use frame_support::{
dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo},
-1
View File
@@ -17,7 +17,6 @@
//! Test utilities
use core::convert::{TryFrom, TryInto};
pub use sp_core::H256;
use sp_runtime::traits::Hash;
pub use sp_runtime::{
+1 -1
View File
@@ -19,7 +19,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{traits::ConstU32, BoundedVec};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
/// A Multihash instance that only supports the basic functionality and no hashing.
#[derive(
@@ -2,7 +2,7 @@
name = "pallet-example-frame-crate"
version = "0.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
license = "MIT-0"
homepage = "https://substrate.io"
repository.workspace = true
+1 -1
View File
@@ -4,7 +4,7 @@ name = "pallet-mixnet"
version = "0.4.0"
license = "Apache-2.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
readme = "README.md"
@@ -47,7 +47,7 @@ pub mod weights;
pub use pallet::*;
use sp_core::OpaquePeerId as PeerId;
use sp_runtime::traits::StaticLookup;
use sp_std::{collections::btree_set::BTreeSet, iter::FromIterator, prelude::*};
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
pub use weights::WeightInfo;
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
-1
View File
@@ -79,7 +79,6 @@ pub mod mock;
mod tests;
pub mod weights;
use core::convert::TryInto;
use frame_support::{
defensive_assert,
pallet_prelude::*,
+1 -1
View File
@@ -2,7 +2,7 @@
name = "pallet-sassafras"
version = "0.3.5-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
@@ -17,7 +17,7 @@
//! RPC interface for the transaction payment pallet.
use std::{convert::TryInto, sync::Arc};
use std::sync::Arc;
use codec::{Codec, Decode};
use jsonrpsee::{
+1 -1
View File
@@ -87,7 +87,7 @@ use frame_support::{
};
use frame_system::pallet_prelude::*;
use sp_runtime::{traits::Dispatchable, DispatchResult};
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
pub use pallet::*;
pub use weights::*;
@@ -3,7 +3,7 @@ name = "sp-consensus-sassafras"
version = "0.3.4-dev"
authors.workspace = true
description = "Primitives for Sassafras consensus"
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/polkadot-sdk/"
@@ -2,6 +2,7 @@
name = "sp-core-fuzz"
version = "0.0.0"
publish = false
edition.workspace = true
[lints]
workspace = true
+1 -1
View File
@@ -4,7 +4,7 @@ name = "sp-mixnet"
version = "0.4.0"
license = "Apache-2.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
edition.workspace = true
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
readme = "README.md"
@@ -33,7 +33,6 @@ use sp_trie::{empty_child_trie_root, LayoutV0, LayoutV1, TrieConfiguration};
use std::{
any::{Any, TypeId},
collections::BTreeMap,
iter::FromIterator,
};
/// Simple Map-based Externalities impl.