diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index bfc496dd2fa3b..9aaea57b0cdb2 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -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::>(); diff --git a/core/consensus/babe/primitives/src/digest.rs b/core/consensus/babe/primitives/src/digest.rs index 3f275ecdb6341..ff62ae29c5293 100644 --- a/core/consensus/babe/primitives/src/digest.rs +++ b/core/consensus/babe/primitives/src/digest.rs @@ -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)] diff --git a/core/consensus/babe/src/aux_schema.rs b/core/consensus/babe/src/aux_schema.rs index 67f61050fa31a..6290d5cf31643 100644 --- a/core/consensus/babe/src/aux_schema.rs +++ b/core/consensus/babe/src/aux_schema.rs @@ -38,7 +38,7 @@ fn load_decode(backend: &B, key: &[u8]) -> ClientResult> 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), diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 1d54cb5c2ee6c..186288c174432 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -38,7 +38,7 @@ fn load_decode(backend: &C, key: &[u8]) -> ClientResult> 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) } diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index fd86a0f277331..e33d00d25531f 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -189,9 +189,9 @@ pub trait SimpleSlotWorker { 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(_), _)) => @@ -220,9 +220,9 @@ pub trait SimpleSlotWorker { } 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, @@ -401,9 +401,8 @@ impl SlotDuration { .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; diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 3841084d1194d..9d1e3f563f8f9 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -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, N, RA, SC, VR, X>( grandpa_params: GrandpaParams, ) -> ::client::error::Result + Send + 'static> where diff --git a/core/primitives/src/ed25519.rs b/core/primitives/src/ed25519.rs index c40499a3a182e..b674a150c4799 100644 --- a/core/primitives/src/ed25519.rs +++ b/core/primitives/src/ed25519.rs @@ -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]); @@ -152,13 +153,6 @@ impl<'de> Deserialize<'de> for Public { } } -#[cfg(feature = "std")] -impl std::hash::Hash for Public { - fn hash(&self, state: &mut H) { - self.0.hash(state); - } -} - /// A signature (a 512-bit value). #[derive(Encode, Decode)] pub struct Signature(pub [u8; 64]); diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 0e573f49ce34c..ed8bb72c9eded 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -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]); @@ -151,13 +152,6 @@ impl<'de> Deserialize<'de> for Public { } } -#[cfg(feature = "std")] -impl std::hash::Hash for Public { - fn hash(&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 diff --git a/core/rpc-servers/src/lib.rs b/core/rpc-servers/src/lib.rs index a23b4a0899734..3f408f6684a03 100644 --- a/core/rpc-servers/src/lib.rs +++ b/core/rpc-servers/src/lib.rs @@ -16,7 +16,7 @@ //! Substrate RPC servers. -#[warn(missing_docs)] +#![warn(missing_docs)] use std::io; use jsonrpc_core::IoHandlerExtension; diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index 0858534482f4b..e6d7df33c2a1d 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -46,7 +46,7 @@ macro_rules! export_blocks { let last_: u64 = last.saturated_into::(); let block_: u64 = block.saturated_into::(); let len: u64 = last_ - block_ + 1; - $output.write(&len.encode())?; + $output.write_all(&len.encode())?; } loop { @@ -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, diff --git a/srml/support/src/hash.rs b/srml/support/src/hash.rs index 3775ebc26bc3b..cbd78f603241e 100644 --- a/srml/support/src/hash.rs +++ b/srml/support/src/hash.rs @@ -59,7 +59,7 @@ impl StorageHasher for Twox64Concat { type Output = Vec; fn hash(x: &[u8]) -> Vec { twox_64(x) - .into_iter() + .iter() .chain(x.into_iter()) .cloned() .collect::>() diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index cd11b56612e74..05f3cd070c267 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -148,7 +148,7 @@ pub trait OnUnbalanced { fn on_unbalanced(amount: Imbalance); } -impl OnUnbalanced for () { +impl OnUnbalanced for () { fn on_unbalanced(amount: Imbalance) { drop(amount); } } diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index caa6d573b0ea8..76cbe7cbab187 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -567,7 +567,7 @@ impl Module { // We perform early return if we've reached the maximum capacity of the event list, // so `Events` seems to be corrupted. Also, this has happened after the start of execution // (since the event list is cleared at the block initialization). - if >::append([event].into_iter()).is_err() { + if >::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;