From 90113303f12cad912657889f3bbdfedf70e80e4b Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 17 Feb 2021 15:38:25 +0300 Subject: [PATCH] Fix updated clippy grumbles (#733) * Revert "Pin Rust Nightly to 2020-12-17 (#652)" This reverts commit e54e6f7e3d34c28d698e637f9099162b3c1917e9. * fix clippy * clippy again * more clippy in test code * and new cargo fmt * another try --- bridges/bin/millau/runtime/src/lib.rs | 2 ++ bridges/bin/rialto/runtime/src/lib.rs | 2 ++ bridges/modules/call-dispatch/src/lib.rs | 3 +++ bridges/modules/currency-exchange/src/lib.rs | 3 +++ bridges/modules/ethereum-contract/builtin/src/lib.rs | 6 +++--- bridges/modules/ethereum/src/mock.rs | 3 +++ bridges/modules/finality-verifier/src/mock.rs | 3 +++ bridges/modules/message-lane/src/mock.rs | 3 +++ bridges/modules/shift-session-manager/src/lib.rs | 3 +++ bridges/modules/substrate/src/mock.rs | 2 ++ bridges/primitives/header-chain/src/justification.rs | 4 ++-- bridges/relays/ethereum-client/src/error.rs | 3 +-- bridges/relays/ethereum/src/main.rs | 2 -- bridges/relays/substrate-client/src/error.rs | 3 +-- 14 files changed, 31 insertions(+), 11 deletions(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 7a4bcae9668f..821796702076 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -23,6 +23,8 @@ #![allow(clippy::large_enum_variant)] // Runtime-generated DecodeLimit::decode_all_With_depth_limit #![allow(clippy::unnecessary_mut_passed)] +// From construct_runtime macro +#![allow(clippy::from_over_into)] // Make the WASM binary available. #[cfg(feature = "std")] diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index fc6ae5b01b4b..4881dea29829 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -23,6 +23,8 @@ #![allow(clippy::large_enum_variant)] // Runtime-generated DecodeLimit::decode_all_With_depth_limit #![allow(clippy::unnecessary_mut_passed)] +// From construct_runtime macro +#![allow(clippy::from_over_into)] // Make the WASM binary available. #[cfg(feature = "std")] diff --git a/bridges/modules/call-dispatch/src/lib.rs b/bridges/modules/call-dispatch/src/lib.rs index 5eeca178d148..7f4132245545 100644 --- a/bridges/modules/call-dispatch/src/lib.rs +++ b/bridges/modules/call-dispatch/src/lib.rs @@ -394,6 +394,9 @@ where #[cfg(test)] mod tests { + // From construct_runtime macro + #![allow(clippy::from_over_into)] + use super::*; use frame_support::{parameter_types, weights::Weight}; use frame_system::{EventRecord, Phase}; diff --git a/bridges/modules/currency-exchange/src/lib.rs b/bridges/modules/currency-exchange/src/lib.rs index 9d1eb9f4489b..7c7d7e4a4d0f 100644 --- a/bridges/modules/currency-exchange/src/lib.rs +++ b/bridges/modules/currency-exchange/src/lib.rs @@ -210,6 +210,9 @@ fn prepare_deposit_details, I: Instance>( #[cfg(test)] mod tests { + // From construct_runtime macro + #![allow(clippy::from_over_into)] + use super::*; use bp_currency_exchange::LockFundsTransaction; use frame_support::{assert_noop, assert_ok, construct_runtime, parameter_types, weights::Weight}; diff --git a/bridges/modules/ethereum-contract/builtin/src/lib.rs b/bridges/modules/ethereum-contract/builtin/src/lib.rs index abb7375103df..5762d510b2a9 100644 --- a/bridges/modules/ethereum-contract/builtin/src/lib.rs +++ b/bridges/modules/ethereum-contract/builtin/src/lib.rs @@ -85,7 +85,7 @@ pub fn from_substrate_block_number(number: BlockNumber) -> Result { /// Parse Substrate header. pub fn parse_substrate_header(raw_header: &[u8]) -> Result { - let substrate_header = RuntimeHeader::decode(&mut &raw_header[..]) + let substrate_header = RuntimeHeader::decode(&mut &*raw_header) .map(|header| Header { hash: header.hash(), parent_hash: header.parent_hash, @@ -100,7 +100,7 @@ pub fn parse_substrate_header(raw_header: &[u8]) -> Result { } }) }) - .and_then(|log| ConsensusLog::decode(&mut &log[..]).ok()) + .and_then(|log| ConsensusLog::decode(&mut &*log).ok()) .and_then(|log| match log { ConsensusLog::ScheduledChange(scheduled_change) => Some(ValidatorsSetSignal { delay: scheduled_change.delay, @@ -133,7 +133,7 @@ pub fn verify_substrate_finality_proof( raw_best_set: &[u8], raw_finality_proof: &[u8], ) -> Result<(), Error> { - let best_set = AuthorityList::decode(&mut &raw_best_set[..]) + let best_set = AuthorityList::decode(&mut &*raw_best_set) .map_err(Error::BestSetDecode) .and_then(|authorities| VoterSet::new(authorities.into_iter()).ok_or(Error::InvalidBestSet)); diff --git a/bridges/modules/ethereum/src/mock.rs b/bridges/modules/ethereum/src/mock.rs index bf5fc54da6e7..6808062d4d0c 100644 --- a/bridges/modules/ethereum/src/mock.rs +++ b/bridges/modules/ethereum/src/mock.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +// From construct_runtime macro +#![allow(clippy::from_over_into)] + pub use crate::test_utils::{insert_header, validator_utils::*, validators_change_receipt, HeaderBuilder, GAS_LIMIT}; pub use bp_eth_poa::signatures::secret_to_address; diff --git a/bridges/modules/finality-verifier/src/mock.rs b/bridges/modules/finality-verifier/src/mock.rs index b78cce664ba9..26890d9d23a1 100644 --- a/bridges/modules/finality-verifier/src/mock.rs +++ b/bridges/modules/finality-verifier/src/mock.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +// From construct_runtime macro +#![allow(clippy::from_over_into)] + use crate::pallet::{BridgedHeader, Config}; use bp_runtime::{BlockNumberOf, Chain}; use frame_support::{construct_runtime, parameter_types, weights::Weight}; diff --git a/bridges/modules/message-lane/src/mock.rs b/bridges/modules/message-lane/src/mock.rs index 340360a12680..948c107d0518 100644 --- a/bridges/modules/message-lane/src/mock.rs +++ b/bridges/modules/message-lane/src/mock.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +// From construct_runtime macro +#![allow(clippy::from_over_into)] + use crate::Config; use bp_message_lane::{ diff --git a/bridges/modules/shift-session-manager/src/lib.rs b/bridges/modules/shift-session-manager/src/lib.rs index ef96fc5318c1..6fc92d73eceb 100644 --- a/bridges/modules/shift-session-manager/src/lib.rs +++ b/bridges/modules/shift-session-manager/src/lib.rs @@ -86,6 +86,9 @@ impl Module { #[cfg(test)] mod tests { + // From construct_runtime macro + #![allow(clippy::from_over_into)] + use super::*; use frame_support::sp_io::TestExternalities; use frame_support::sp_runtime::{ diff --git a/bridges/modules/substrate/src/mock.rs b/bridges/modules/substrate/src/mock.rs index c13c466c3a81..85782b7ea4fe 100644 --- a/bridges/modules/substrate/src/mock.rs +++ b/bridges/modules/substrate/src/mock.rs @@ -19,6 +19,8 @@ //! Includes some useful testing types and functions. #![cfg(test)] +// From construct_runtime macro +#![allow(clippy::from_over_into)] use crate::{BridgedBlockHash, BridgedBlockNumber, BridgedHeader, Config}; use bp_runtime::Chain; diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs index 3e4b9043c08a..929ef17bdca2 100644 --- a/bridges/primitives/header-chain/src/justification.rs +++ b/bridges/primitives/header-chain/src/justification.rs @@ -48,7 +48,7 @@ pub enum Error { pub fn decode_justification_target( raw_justification: &[u8], ) -> Result<(Header::Hash, Header::Number), Error> { - GrandpaJustification::
::decode(&mut &raw_justification[..]) + GrandpaJustification::
::decode(&mut &*raw_justification) .map(|justification| (justification.commit.target_hash, justification.commit.target_number)) .map_err(|_| Error::JustificationDecode) } @@ -65,7 +65,7 @@ where { // Decode justification first let justification = - GrandpaJustification::
::decode(&mut &raw_justification[..]).map_err(|_| Error::JustificationDecode)?; + GrandpaJustification::
::decode(&mut &*raw_justification).map_err(|_| Error::JustificationDecode)?; // Ensure that it is justification for the expected header if (justification.commit.target_hash, justification.commit.target_number) != finalized_target { diff --git a/bridges/relays/ethereum-client/src/error.rs b/bridges/relays/ethereum-client/src/error.rs index afcc3c678254..0f47891138ab 100644 --- a/bridges/relays/ethereum-client/src/error.rs +++ b/bridges/relays/ethereum-client/src/error.rs @@ -57,8 +57,7 @@ impl MaybeConnectionError for Error { fn is_connection_error(&self) -> bool { matches!( *self, - Error::Request(RequestError::TransportError(_)) - | Error::ClientNotSynced(_), + Error::Request(RequestError::TransportError(_)) | Error::ClientNotSynced(_), ) } } diff --git a/bridges/relays/ethereum/src/main.rs b/bridges/relays/ethereum/src/main.rs index 1dd5dd0442aa..b75c0f44bb85 100644 --- a/bridges/relays/ethereum/src/main.rs +++ b/bridges/relays/ethereum/src/main.rs @@ -63,7 +63,6 @@ fn main() { .is_err() { log::error!(target: "bridge", "Unable to get Substrate genesis block for Ethereum sync."); - return; }; } ("sub-to-eth", Some(sub_to_eth_matches)) => { @@ -78,7 +77,6 @@ fn main() { .is_err() { log::error!(target: "bridge", "Unable to get Substrate genesis block for Substrate sync."); - return; }; } ("eth-deploy-contract", Some(eth_deploy_matches)) => { diff --git a/bridges/relays/substrate-client/src/error.rs b/bridges/relays/substrate-client/src/error.rs index f5bb250d9fb4..67aefe988553 100644 --- a/bridges/relays/substrate-client/src/error.rs +++ b/bridges/relays/substrate-client/src/error.rs @@ -61,8 +61,7 @@ impl MaybeConnectionError for Error { fn is_connection_error(&self) -> bool { matches!( *self, - Error::Request(RequestError::TransportError(_)) - | Error::ClientNotSynced(_) + Error::Request(RequestError::TransportError(_)) | Error::ClientNotSynced(_) ) } }