Skip to content

Commit

Permalink
remove unnessisary use statements due to 2021 core prelude (#4183)
Browse files Browse the repository at this point in the history
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`)
  • Loading branch information
gilescope authored and Morganamilo committed May 2, 2024
1 parent 9c8eef8 commit 991f367
Show file tree
Hide file tree
Showing 56 changed files with 46 additions and 82 deletions.
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/messages_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/messages_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/messages_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> =
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/inbound-queue/src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/inbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/beacon/src/bits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
use sp_std::{convert::TryInto, prelude::*};
use sp_std::prelude::*;
use ssz_rs::{Bitvector, Deserialize};

pub fn decompress_sync_committee_bits<
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/beacon/src/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/ethereum/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/ethereum/src/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/runtime/test-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "snowbridge-runtime-test-common"
description = "Snowbridge Runtime Tests"
version = "0.2.0"
authors = ["Snowfork <[email protected]>"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
categories = ["cryptography::cryptocurrencies"]

Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/consensus/aura/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/pallets/collective-content/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pallet-collective-content"
version = "0.6.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
edition.workspace = true
description = "Managed content"
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/core/bitfield-signing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/network/bitfield-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use std::{
collections::{HashMap, HashSet},
convert::TryInto,
time::Duration,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion polkadot/xcm/src/v3/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/src/v3/junctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions polkadot/xcm/src/v3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions polkadot/xcm/src/v3/multiasset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions polkadot/xcm/src/v3/multilocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {}

Expand Down
5 changes: 1 addition & 4 deletions polkadot/xcm/src/v4/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion polkadot/xcm/src/v4/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/src/v4/junctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions polkadot/xcm/src/v4/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {}

Expand Down
6 changes: 1 addition & 5 deletions polkadot/xcm/src/v4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion polkadot/xcm/xcm-builder/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/consensus/grandpa/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion substrate/client/consensus/grandpa/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use std::{
collections::{BTreeMap, HashMap},
iter::FromIterator,
marker::PhantomData,
pin::Pin,
sync::Arc,
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/mixnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
edition = "2021"
edition.workspace = true
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
readme = "README.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use futures::prelude::*;
use libp2p::core::upgrade::{InboundUpgrade, ProtocolName, UpgradeInfo};
use std::{
iter::FromIterator,
pin::Pin,
task::{Context, Poll},
vec,
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "polkadot-sdk-frame"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
homepage = "paritytech.github.io"
repository.workspace = true
Expand Down
Loading

0 comments on commit 991f367

Please sign in to comment.