Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relaxed clippy fixes/nits #2661

Merged
merged 25 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cumulus/parachain-template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;

use parachain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};

pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand Down
1 change: 0 additions & 1 deletion cumulus/parachain-template/runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ pub mod rocksdb_weights;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ pub mod xcm;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ pub mod xcm;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub mod xcm;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;

use crate::Runtime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub mod xcm;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;

use crate::Runtime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ pub mod rocksdb_weights;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use pallet_contracts::{
};
use sp_runtime::Perbill;

pub use parachains_common::{rococo::currency::deposit, AVERAGE_ON_INITIALIZE_RATIO};
pub use parachains_common::rococo::currency::deposit;

// Prints debug output of the `contracts` pallet to stdout if the node is
// started with `-lruntime::contracts=debug`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ pub mod rocksdb_weights;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ pub mod rocksdb_weights;

pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
2 changes: 1 addition & 1 deletion cumulus/polkadot-parachain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::sync::Arc;

use parachains_common::{AccountId, Balance, Block, Nonce};
use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand Down
2 changes: 1 addition & 1 deletion cumulus/polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use sp_core::Pair;
use jsonrpsee::RpcModule;

use crate::{fake_runtime_api::aura::RuntimeApi, rpc};
pub use parachains_common::{AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce};
pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Nonce};

use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
use futures::{lock::Mutex, prelude::*};
Expand Down
2 changes: 0 additions & 2 deletions cumulus/primitives/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
#[cfg(feature = "std")]
mod client_side;
#[cfg(feature = "std")]
pub use client_side::*;
#[cfg(feature = "std")]
mod mock;
#[cfg(feature = "std")]
pub use mock::{MockValidationDataInherentDataProvider, MockXcmConfig};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tokio::{runtime::Handle, sync::Mutex};

const TEST_PREPARATION_TIMEOUT: Duration = Duration::from_secs(30);

#[allow(dead_code)]
struct TestHost {
// Keep a reference to the tempdir otherwise it gets deleted on drop.
#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/malus/src/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! messages on the overseer level.

use polkadot_node_subsystem::*;
pub use polkadot_node_subsystem::{messages, messages::*, overseer, FromOrchestra};
pub use polkadot_node_subsystem::{messages::*, overseer, FromOrchestra};
use std::{future::Future, pin::Pin};

/// Filter incoming and outgoing messages.
Expand Down
5 changes: 0 additions & 5 deletions polkadot/node/network/bridge/src/rx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ use polkadot_node_subsystem::{

use polkadot_primitives::{AuthorityDiscoveryId, BlockNumber, Hash, ValidatorIndex};

/// Peer set info for network initialization.
///
/// To be passed to [`FullNetworkConfiguration::add_notification_protocol`]().
pub use polkadot_node_network_protocol::peer_set::{peer_sets_info, IsAuthority};

use std::{
collections::{hash_map, HashMap},
iter::ExactSizeIterator,
Expand Down
1 change: 0 additions & 1 deletion polkadot/node/network/bridge/src/tx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use polkadot_node_subsystem::{
/// Peer set info for network initialization.
///
/// To be passed to [`FullNetworkConfiguration::add_notification_protocol`]().
bkontur marked this conversation as resolved.
Show resolved Hide resolved
pub use polkadot_node_network_protocol::peer_set::{peer_sets_info, IsAuthority};
use polkadot_node_network_protocol::request_response::Requests;
use sc_network::{MessageSink, ReputationChange};

Expand Down
5 changes: 1 addition & 4 deletions polkadot/node/service/src/parachains_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ pub(crate) mod columns {

// Version 4 only changed structures in approval voting, so we can re-export the v4 definitions.
pub mod v3 {
pub use super::v4::{
COL_APPROVAL_DATA, COL_AVAILABILITY_DATA, COL_AVAILABILITY_META,
COL_CHAIN_SELECTION_DATA, COL_DISPUTE_COORDINATOR_DATA, NUM_COLUMNS, ORDERED_COL,
};
pub use super::v4::{NUM_COLUMNS, ORDERED_COL};
}

pub mod v4 {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/tracking-allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ unsafe impl<A: GlobalAlloc> GlobalAlloc for TrackingAllocator<A> {
}

#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) -> () {
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
let guard = ALLOCATOR_DATA.lock();
TrackingAllocatorData::track_and_check_limits(guard, -(layout.size() as isize));
self.0.dealloc(ptr, layout)
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ impl<T: Config> Pallet<T> {
}

// We first need to deposit the balance to ensure that the account exists.
CurrencyOf::<T>::deposit_creating(&dest, balance_due);
let _ = CurrencyOf::<T>::deposit_creating(&dest, balance_due);

// Check if this claim should have a vesting schedule.
if let Some(vs) = vesting {
Expand Down
7 changes: 6 additions & 1 deletion polkadot/runtime/parachains/src/assigner_on_demand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ where
ensure!(spot_price.le(&max_amount), Error::<T>::SpotPriceHigherThanMaxAmount);

// Charge the sending account the spot price
T::Currency::withdraw(&sender, spot_price, WithdrawReasons::FEE, existence_requirement)?;
let _ = T::Currency::withdraw(
&sender,
spot_price,
WithdrawReasons::FEE,
existence_requirement,
)?;

let assignment = Assignment::new(para_id);

Expand Down
4 changes: 1 addition & 3 deletions polkadot/xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ use polkadot_parachain_primitives::primitives::Id as ParaId;
use polkadot_runtime_parachains::origin;
use sp_core::H256;
use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
pub use sp_std::{
cell::RefCell, collections::btree_map::BTreeMap, fmt::Debug, marker::PhantomData,
};
pub use sp_std::cell::RefCell;
use xcm::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
Expand Down
28 changes: 14 additions & 14 deletions polkadot/xcm/procedural/src/builder_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ fn generate_builder_raw_impl(name: &Ident, data_enum: &DataEnum) -> TokenStream2
let methods = data_enum.variants.iter().map(|variant| {
let variant_name = &variant.ident;
let method_name_string = &variant_name.to_string().to_snake_case();
let method_name = syn::Ident::new(&method_name_string, variant_name.span());
let docs = get_doc_comments(&variant);
let method_name = syn::Ident::new(method_name_string, variant_name.span());
let docs = get_doc_comments(variant);
let method = match &variant.fields {
Fields::Unit => {
quote! {
Expand Down Expand Up @@ -149,7 +149,7 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
.map(|variant| {
let maybe_builder_attr = variant.attrs.iter().find(|attr| match attr.meta {
Meta::List(ref list) => {
return list.path.is_ident("builder");
list.path.is_ident("builder")
},
_ => false,
});
Expand All @@ -159,7 +159,7 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
* holding register */
};
let Meta::List(ref list) = builder_attr.meta else { unreachable!("We checked before") };
let inner_ident: Ident = syn::parse2(list.tokens.clone().into()).map_err(|_| {
let inner_ident: Ident = syn::parse2(list.tokens.clone()).map_err(|_| {
Error::new_spanned(&builder_attr, "Expected `builder(loads_holding)`")
})?;
let ident_to_match: Ident = syn::parse_quote!(loads_holding);
Expand All @@ -177,8 +177,8 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
.map(|variant| {
let variant_name = &variant.ident;
let method_name_string = &variant_name.to_string().to_snake_case();
let method_name = syn::Ident::new(&method_name_string, variant_name.span());
let docs = get_doc_comments(&variant);
let method_name = syn::Ident::new(method_name_string, variant_name.span());
let docs = get_doc_comments(variant);
let method = match &variant.fields {
Fields::Unnamed(fields) => {
let arg_names: Vec<_> = fields
Expand Down Expand Up @@ -217,7 +217,7 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
},
_ =>
return Err(Error::new_spanned(
&variant,
variant,
"Instructions that load the holding register should take operands",
)),
};
Expand All @@ -235,14 +235,14 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
let buy_execution_method = data_enum
.variants
.iter()
.find(|variant| variant.ident.to_string() == "BuyExecution")
.find(|variant| variant.ident == "BuyExecution")
.map_or(
Err(Error::new_spanned(&data_enum.variants, "No BuyExecution instruction")),
|variant| {
let variant_name = &variant.ident;
let method_name_string = &variant_name.to_string().to_snake_case();
let method_name = syn::Ident::new(&method_name_string, variant_name.span());
let docs = get_doc_comments(&variant);
let method_name = syn::Ident::new(method_name_string, variant_name.span());
let docs = get_doc_comments(variant);
let fields = match &variant.fields {
Fields::Named(fields) => {
let arg_names: Vec<_> =
Expand All @@ -263,7 +263,7 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result<TokenStre
},
_ =>
return Err(Error::new_spanned(
&variant,
variant,
"BuyExecution should have named fields",
)),
};
Expand All @@ -289,19 +289,19 @@ fn generate_builder_unpaid_impl(name: &Ident, data_enum: &DataEnum) -> Result<To
let unpaid_execution_variant = data_enum
.variants
.iter()
.find(|variant| variant.ident.to_string() == "UnpaidExecution")
.find(|variant| variant.ident == "UnpaidExecution")
.ok_or(Error::new_spanned(&data_enum.variants, "No UnpaidExecution instruction"))?;
let unpaid_execution_ident = &unpaid_execution_variant.ident;
let unpaid_execution_method_name = Ident::new(
&unpaid_execution_ident.to_string().to_snake_case(),
unpaid_execution_ident.span(),
);
let docs = get_doc_comments(&unpaid_execution_variant);
let docs = get_doc_comments(unpaid_execution_variant);
let fields = match &unpaid_execution_variant.fields {
Fields::Named(fields) => fields,
_ =>
return Err(Error::new_spanned(
&unpaid_execution_variant,
unpaid_execution_variant,
"UnpaidExecution should have named fields",
)),
};
Expand Down
4 changes: 2 additions & 2 deletions polkadot/xcm/xcm-builder/src/currency_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<
.map_err(|_| XcmError::NotWithdrawable)
}
fn accrue_checked(checked_account: AccountId, amount: Currency::Balance) {
Currency::deposit_creating(&checked_account, amount);
let _ = Currency::deposit_creating(&checked_account, amount);
Currency::deactivate(amount);
}
fn reduce_checked(checked_account: AccountId, amount: Currency::Balance) {
Expand Down Expand Up @@ -215,7 +215,7 @@ impl<
let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
let who =
AccountIdConverter::convert_location(who).ok_or(Error::AccountIdConversionFailed)?;
Currency::withdraw(&who, amount, WithdrawReasons::TRANSFER, AllowDeath)
let _ = Currency::withdraw(&who, amount, WithdrawReasons::TRANSFER, AllowDeath)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(what.clone().into())
}
Expand Down
8 changes: 2 additions & 6 deletions polkadot/xcm/xcm-builder/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@ pub use crate::{
};
use frame_support::traits::{ContainsPair, Everything};
pub use frame_support::{
dispatch::{
DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, Parameter, PostDispatchInfo,
},
dispatch::{DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo},
ensure, match_types, parameter_types,
sp_runtime::{traits::Dispatchable, DispatchError, DispatchErrorWithPostInfo},
traits::{ConstU32, Contains, Get, IsInVec},
traits::{Contains, Get, IsInVec},
};
pub use parity_scale_codec::{Decode, Encode};
pub use sp_io::hashing::blake2_256;
pub use sp_std::{
cell::{Cell, RefCell},
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
fmt::Debug,
marker::PhantomData,
};
pub use xcm::latest::{prelude::*, Weight};
use xcm_executor::traits::{Properties, QueryHandler, QueryResponseStatus};
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/chain-spec/src/genesis_config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ where
mod tests {
use super::*;
use serde_json::{from_str, json};
pub use sp_consensus_babe::{AllowedSlots, BabeEpochConfiguration, Slot};
pub use sp_consensus_babe::{AllowedSlots, BabeEpochConfiguration};

#[test]
fn get_default_config_works() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ pub use self::{
},
};

#[cfg(test)]
pub use self::notifications::{
NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen,
};

mod collec;
mod notifications;
8 changes: 2 additions & 6 deletions substrate/frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@

pub use sp_core::H256;
use sp_runtime::traits::Hash;
pub use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
pub use sp_runtime::{traits::BlakeTwo256, BuildStorage};
use sp_std::convert::{TryFrom, TryInto};

pub use frame_support::{
assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types,
traits::{EitherOfDiverse, SortedMembers},
BoundedVec,
traits::EitherOfDiverse, BoundedVec,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_identity::{
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn add_sufficients<T: Config<I>, I: 'static>(minter: T::AccountId, n: u32) {

fn add_approvals<T: Config<I>, I: 'static>(minter: T::AccountId, n: u32) {
let asset_id = default_asset_id::<T, I>();
T::Currency::deposit_creating(
let _ = T::Currency::deposit_creating(
&minter,
T::ApprovalDeposit::get() * n.into() + T::Currency::minimum_balance(),
);
Expand Down
5 changes: 1 addition & 4 deletions substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ use sp_state_machine::BasicExternalities;

use crate as pallet_beefy;

pub use sp_consensus_beefy::{
ecdsa_crypto::{AuthorityId as BeefyId, AuthoritySignature as BeefySignature},
ConsensusLog, EquivocationProof, BEEFY_ENGINE_ID,
};
pub use sp_consensus_beefy::{ecdsa_crypto::AuthorityId as BeefyId, ConsensusLog, BEEFY_ENGINE_ID};

impl_opaque_keys! {
pub struct MockSessionKeys {
Expand Down
2 changes: 0 additions & 2 deletions substrate/frame/broker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ pub use weights::WeightInfo;
pub use adapt_price::*;
pub use core_mask::*;
pub use coretime_interface::*;
pub use nonfungible_impl::*;
pub use types::*;
pub use utility_impls::*;

#[frame_support::pallet]
pub mod pallet {
Expand Down
Loading
Loading