Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
It's Clippy time
Browse files Browse the repository at this point in the history
Fix some Clippy issues
  • Loading branch information
c410-f3r committed Oct 19, 2019
1 parent e479a51 commit 5a2e743
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/client/db/src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> {
// prepare list of caches that are not update
// (we might still need to do some cache maintenance in this case)
let missed_caches = self.cache.cache_at.keys()
.filter(|cache| !data_at.contains_key(cache.clone()))
.filter(|cache| !data_at.contains_key(*cache))
.cloned()
.collect::<Vec<_>>();

Expand Down
2 changes: 1 addition & 1 deletion core/consensus/babe/primitives/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl BabePreDigest {
}

/// The prefix used by BABE for its VRF keys.
pub const BABE_VRF_PREFIX: &'static [u8] = b"substrate-babe-vrf";
pub const BABE_VRF_PREFIX: &[u8] = b"substrate-babe-vrf";

/// A raw version of `BabePreDigest`, usable on `no_std`.
#[derive(Copy, Clone, Encode, Decode)]
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/babe/src/aux_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn load_decode<B, T>(backend: &B, key: &[u8]) -> ClientResult<Option<T>>
T: Decode,
{
let corrupt = |e: codec::Error| {
ClientError::Backend(format!("BABE DB is corrupted. Decode error: {}", e.what())).into()
ClientError::Backend(format!("BABE DB is corrupted. Decode error: {}", e.what()))
};
match backend.get_aux(key)? {
None => Ok(None),
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/slots/src/aux_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn load_decode<C, T>(backend: &C, key: &[u8]) -> ClientResult<Option<T>>
None => Ok(None),
Some(t) => T::decode(&mut &t[..])
.map_err(
|e| ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e.what())).into(),
|e| ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e.what())),
)
.map(Some)
}
Expand Down
11 changes: 5 additions & 6 deletions core/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
logs,
},
remaining_duration,
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)).into()),
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e))),
Delay::new(remaining_duration)
.map_err(|err| consensus_common::Error::FaultyTimer(err).into())
.map_err(consensus_common::Error::FaultyTimer)
).map(|v| match v {
futures::future::Either::Left((b, _)) => b.map(|b| (b, claim)),
futures::future::Either::Right((Ok(_), _)) =>
Expand Down Expand Up @@ -220,9 +220,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
}

let (header, body) = block.deconstruct();
let header_num = header.number().clone();
let header_num = *header.number();
let header_hash = header.hash();
let parent_hash = header.parent_hash().clone();
let parent_hash = *header.parent_hash();

let block_import_params = block_import_params_maker(
header,
Expand Down Expand Up @@ -401,9 +401,8 @@ impl<T: Clone> SlotDuration<T> {
.map_err(|_| {
client::error::Error::Backend({
error!(target: "slots", "slot duration kept in invalid format");
format!("slot duration kept in invalid format")
"slot duration kept in invalid format".to_string()
})
.into()
}),
None => {
use sr_primitives::traits::Zero;
Expand Down
2 changes: 1 addition & 1 deletion core/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ where
}
}

#[deprecated(since = "1.1", note = "Please switch to run_grandpa_voter.")]
#[deprecated(since = "1.1.0", note = "Please switch to run_grandpa_voter.")]
pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
grandpa_params: GrandpaParams<B, E, Block, N, RA, SC, VR, X>,
) -> ::client::error::Result<impl Future<Item=(),Error=()> + Send + 'static> where
Expand Down
8 changes: 1 addition & 7 deletions core/primitives/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}};
type Seed = [u8; 32];

/// A public key.
#[cfg_attr(feature = "std", derive(Hash))]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
pub struct Public(pub [u8; 32]);

Expand Down Expand Up @@ -152,13 +153,6 @@ impl<'de> Deserialize<'de> for Public {
}
}

#[cfg(feature = "std")]
impl std::hash::Hash for Public {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}

/// A signature (a 512-bit value).
#[derive(Encode, Decode)]
pub struct Signature(pub [u8; 64]);
Expand Down
8 changes: 1 addition & 7 deletions core/primitives/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use schnorrkel::keys::{MINI_SECRET_KEY_LENGTH, SECRET_KEY_LENGTH};
const SIGNING_CTX: &[u8] = b"substrate";

/// An Schnorrkel/Ristretto x25519 ("sr25519") public key.
#[cfg_attr(feature = "std", derive(Hash))]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
pub struct Public(pub [u8; 32]);

Expand Down Expand Up @@ -151,13 +152,6 @@ impl<'de> Deserialize<'de> for Public {
}
}

#[cfg(feature = "std")]
impl std::hash::Hash for Public {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}

/// An Schnorrkel/Ristretto x25519 ("sr25519") signature.
///
/// Instead of importing it for the local module, alias it to be available as a public type
Expand Down
2 changes: 1 addition & 1 deletion core/rpc-servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Substrate RPC servers.
#[warn(missing_docs)]
#![warn(missing_docs)]

use std::io;
use jsonrpc_core::IoHandlerExtension;
Expand Down
4 changes: 2 additions & 2 deletions core/service/src/chain_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! export_blocks {
let last_: u64 = last.saturated_into::<u64>();
let block_: u64 = block.saturated_into::<u64>();
let len: u64 = last_ - block_ + 1;
$output.write(&len.encode())?;
$output.write_all(&len.encode())?;
}

loop {
Expand All @@ -59,7 +59,7 @@ macro_rules! export_blocks {
serde_json::to_writer(&mut $output, &block)
.map_err(|e| format!("Error writing JSON: {}", e))?;
} else {
$output.write(&block.encode())?;
$output.write_all(&block.encode())?;
}
},
None => break,
Expand Down
2 changes: 1 addition & 1 deletion srml/support/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl StorageHasher for Twox64Concat {
type Output = Vec<u8>;
fn hash(x: &[u8]) -> Vec<u8> {
twox_64(x)
.into_iter()
.iter()
.chain(x.into_iter())
.cloned()
.collect::<Vec<_>>()
Expand Down
2 changes: 1 addition & 1 deletion srml/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub trait OnUnbalanced<Imbalance> {
fn on_unbalanced(amount: Imbalance);
}

impl<Imbalance: Drop> OnUnbalanced<Imbalance> for () {
impl<Imbalance> OnUnbalanced<Imbalance> for () {
fn on_unbalanced(amount: Imbalance) { drop(amount); }
}

Expand Down
2 changes: 1 addition & 1 deletion srml/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl<T: Trait> Module<T> {
// We perform early return if we've reached the maximum capacity of the event list,
// so `Events<T>` seems to be corrupted. Also, this has happened after the start of execution
// (since the event list is cleared at the block initialization).
if <Events<T>>::append([event].into_iter()).is_err() {
if <Events<T>>::append([event].iter()).is_err() {
// The most sensible thing to do here is to just ignore this event and wait until the
// new block.
return;
Expand Down

0 comments on commit 5a2e743

Please sign in to comment.