Skip to content

Commit

Permalink
Fix updated clippy grumbles (paritytech#733)
Browse files Browse the repository at this point in the history
* Revert "Pin Rust Nightly to 2020-12-17 (paritytech#652)"

This reverts commit e54e6f7.

* fix clippy

* clippy again

* more clippy in test code

* and new cargo fmt

* another try
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent 4fe6f3e commit f1a9778
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/call-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/currency-exchange/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ fn prepare_deposit_details<T: Config<I>, 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};
Expand Down
6 changes: 3 additions & 3 deletions bridges/modules/ethereum-contract/builtin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn from_substrate_block_number(number: BlockNumber) -> Result<U256, Error> {

/// Parse Substrate header.
pub fn parse_substrate_header(raw_header: &[u8]) -> Result<Header, Error> {
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,
Expand All @@ -100,7 +100,7 @@ pub fn parse_substrate_header(raw_header: &[u8]) -> Result<Header, Error> {
}
})
})
.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,
Expand Down Expand Up @@ -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));

Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/ethereum/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

// 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;

Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/finality-verifier/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

// 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};
Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/message-lane/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

// From construct_runtime macro
#![allow(clippy::from_over_into)]

use crate::Config;

use bp_message_lane::{
Expand Down
3 changes: 3 additions & 0 deletions bridges/modules/shift-session-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ impl<T: Config> Module<T> {

#[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::{
Expand Down
2 changes: 2 additions & 0 deletions bridges/modules/substrate/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions bridges/primitives/header-chain/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum Error {
pub fn decode_justification_target<Header: HeaderT>(
raw_justification: &[u8],
) -> Result<(Header::Hash, Header::Number), Error> {
GrandpaJustification::<Header>::decode(&mut &raw_justification[..])
GrandpaJustification::<Header>::decode(&mut &*raw_justification)
.map(|justification| (justification.commit.target_hash, justification.commit.target_number))
.map_err(|_| Error::JustificationDecode)
}
Expand All @@ -65,7 +65,7 @@ where
{
// Decode justification first
let justification =
GrandpaJustification::<Header>::decode(&mut &raw_justification[..]).map_err(|_| Error::JustificationDecode)?;
GrandpaJustification::<Header>::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 {
Expand Down
3 changes: 1 addition & 2 deletions bridges/relays/ethereum-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_),
)
}
}
Expand Down
2 changes: 0 additions & 2 deletions bridges/relays/ethereum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) => {
Expand All @@ -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)) => {
Expand Down
3 changes: 1 addition & 2 deletions bridges/relays/substrate-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
)
}
}
Expand Down

0 comments on commit f1a9778

Please sign in to comment.