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

Commit 1b32dbe

Browse files
committed
It's Clippy time!
Compliance with all default hard errors and crates that are explicitly using #![deny(warnings)]. There are some legitimate warnings like println!("") -> println!() but they aren't considered in this PR.
1 parent ce03f37 commit 1b32dbe

File tree

15 files changed

+22
-34
lines changed

15 files changed

+22
-34
lines changed

core/client/db/src/cache/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> {
207207
// prepare list of caches that are not update
208208
// (we might still need to do some cache maintenance in this case)
209209
let missed_caches = self.cache.cache_at.keys()
210-
.filter(|cache| !data_at.contains_key(cache.clone()))
210+
.filter(|cache| !data_at.contains_key(*cache))
211211
.cloned()
212212
.collect::<Vec<_>>();
213213

core/consensus/babe/primitives/src/digest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl BabePreDigest {
9191
}
9292

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

9696
/// A raw version of `BabePreDigest`, usable on `no_std`.
9797
#[derive(Copy, Clone, Encode, Decode)]

core/consensus/babe/src/aux_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn load_decode<B, T>(backend: &B, key: &[u8]) -> ClientResult<Option<T>>
3838
T: Decode,
3939
{
4040
let corrupt = |e: codec::Error| {
41-
ClientError::Backend(format!("BABE DB is corrupted. Decode error: {}", e.what())).into()
41+
ClientError::Backend(format!("BABE DB is corrupted. Decode error: {}", e.what()))
4242
};
4343
match backend.get_aux(key)? {
4444
None => Ok(None),

core/consensus/slots/src/aux_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn load_decode<C, T>(backend: &C, key: &[u8]) -> ClientResult<Option<T>>
3838
None => Ok(None),
3939
Some(t) => T::decode(&mut &t[..])
4040
.map_err(
41-
|e| ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e.what())).into(),
41+
|e| ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e.what())),
4242
)
4343
.map(Some)
4444
}

core/consensus/slots/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
189189
logs,
190190
},
191191
remaining_duration,
192-
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)).into()),
192+
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e))),
193193
Delay::new(remaining_duration)
194-
.map_err(|err| consensus_common::Error::FaultyTimer(err).into())
194+
.map_err(consensus_common::Error::FaultyTimer)
195195
).map(|v| match v {
196196
futures::future::Either::Left((b, _)) => b.map(|b| (b, claim)),
197197
futures::future::Either::Right((Ok(_), _)) =>
@@ -220,9 +220,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
220220
}
221221

222222
let (header, body) = block.deconstruct();
223-
let header_num = header.number().clone();
223+
let header_num = *header.number();
224224
let header_hash = header.hash();
225-
let parent_hash = header.parent_hash().clone();
225+
let parent_hash = *header.parent_hash();
226226

227227
let block_import_params = block_import_params_maker(
228228
header,
@@ -401,9 +401,8 @@ impl<T: Clone> SlotDuration<T> {
401401
.map_err(|_| {
402402
client::error::Error::Backend({
403403
error!(target: "slots", "slot duration kept in invalid format");
404-
format!("slot duration kept in invalid format")
404+
"slot duration kept in invalid format".to_string()
405405
})
406-
.into()
407406
}),
408407
None => {
409408
use sr_primitives::traits::Zero;

core/finality-grandpa/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ where
808808
}
809809
}
810810

811-
#[deprecated(since = "1.1", note = "Please switch to run_grandpa_voter.")]
811+
#[deprecated(since = "1.1.0", note = "Please switch to run_grandpa_voter.")]
812812
pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA, SC, X>(
813813
grandpa_params: GrandpaParams<B, E, Block, N, RA, SC, X>,
814814
) -> ::client::error::Result<impl Future<Item=(),Error=()> + Send + 'static> where

core/primitives/src/ed25519.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}};
4141
type Seed = [u8; 32];
4242

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

@@ -152,13 +153,6 @@ impl<'de> Deserialize<'de> for Public {
152153
}
153154
}
154155

155-
#[cfg(feature = "std")]
156-
impl std::hash::Hash for Public {
157-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
158-
self.0.hash(state);
159-
}
160-
}
161-
162156
/// A signature (a 512-bit value).
163157
#[derive(Encode, Decode)]
164158
pub struct Signature(pub [u8; 64]);

core/primitives/src/sr25519.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use schnorrkel::keys::{MINI_SECRET_KEY_LENGTH, SECRET_KEY_LENGTH};
4747
const SIGNING_CTX: &[u8] = b"substrate";
4848

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

@@ -151,13 +152,6 @@ impl<'de> Deserialize<'de> for Public {
151152
}
152153
}
153154

154-
#[cfg(feature = "std")]
155-
impl std::hash::Hash for Public {
156-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
157-
self.0.hash(state);
158-
}
159-
}
160-
161155
/// An Schnorrkel/Ristretto x25519 ("sr25519") signature.
162156
///
163157
/// Instead of importing it for the local module, alias it to be available as a public type

core/rpc-servers/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
//! Substrate RPC servers.
1818
19-
#[warn(missing_docs)]
19+
#![warn(missing_docs)]
2020

2121
use std::io;
2222
use jsonrpc_core::IoHandlerExtension;

core/service/src/chain_ops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! export_blocks {
4646
let last_: u64 = last.saturated_into::<u64>();
4747
let block_: u64 = block.saturated_into::<u64>();
4848
let len: u64 = last_ - block_ + 1;
49-
$output.write(&len.encode())?;
49+
$output.write_all(&len.encode())?;
5050
}
5151

5252
loop {
@@ -59,7 +59,7 @@ macro_rules! export_blocks {
5959
serde_json::to_writer(&mut $output, &block)
6060
.map_err(|e| format!("Error writing JSON: {}", e))?;
6161
} else {
62-
$output.write(&block.encode())?;
62+
$output.write_all(&block.encode())?;
6363
}
6464
},
6565
None => break,

core/sr-primitives/src/sr_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use crate::serde::{Serialize, Deserialize};
2121

2222
use rstd::{
23-
ops, cmp::Ordering, prelude::*,
23+
ops, ops::Div, cmp::Ordering, prelude::*,
2424
convert::{TryFrom, TryInto},
2525
};
2626
use codec::{Encode, Decode};
@@ -178,7 +178,7 @@ macro_rules! implement_per_thing {
178178
// `rem_multiplied_upper` is less than $max^2 therefore divided by $max it fits
179179
// in $type. remember that $type always fits $max.
180180
let mut rem_multiplied_divided_sized =
181-
(rem_multiplied_upper / upper_max) as $type;
181+
rem_multiplied_upper.div(upper_max) as $type;
182182
// fix a tiny rounding error
183183
if rem_multiplied_upper % upper_max > upper_max / 2 {
184184
rem_multiplied_divided_sized += 1;

core/sr-primitives/src/traits.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,10 @@ pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq {
475475
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
476476
pub struct BlakeTwo256;
477477

478-
impl Hash for BlakeTwo256 {
478+
impl self::Hash for BlakeTwo256 {
479479
type Output = primitives::H256;
480480
type Hasher = Blake2Hasher;
481+
481482
fn hash(s: &[u8]) -> Self::Output {
482483
runtime_io::blake2_256(s).into()
483484
}

srml/support/src/hash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl StorageHasher for Twox64Concat {
5959
type Output = Vec<u8>;
6060
fn hash(x: &[u8]) -> Vec<u8> {
6161
twox_64(x)
62-
.into_iter()
62+
.iter()
6363
.chain(x.into_iter())
6464
.cloned()
6565
.collect::<Vec<_>>()

srml/support/src/traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub trait OnUnbalanced<Imbalance> {
148148
fn on_unbalanced(amount: Imbalance);
149149
}
150150

151-
impl<Imbalance: Drop> OnUnbalanced<Imbalance> for () {
151+
impl<Imbalance> OnUnbalanced<Imbalance> for () {
152152
fn on_unbalanced(amount: Imbalance) { drop(amount); }
153153
}
154154

srml/system/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl<T: Trait> Module<T> {
578578
// We perform early return if we've reached the maximum capacity of the event list,
579579
// so `Events<T>` seems to be corrupted. Also, this has happened after the start of execution
580580
// (since the event list is cleared at the block initialization).
581-
if <Events<T>>::append([event].into_iter()).is_err() {
581+
if <Events<T>>::append([event].iter()).is_err() {
582582
// The most sensible thing to do here is to just ignore this event and wait until the
583583
// new block.
584584
return;

0 commit comments

Comments
 (0)