Apply some clippy lints (#11154)

* Apply some clippy hints

* Revert clippy ci changes

* Update client/cli/src/commands/generate.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/cli/src/commands/inspect_key.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/transactions.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/protocol.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Revert due to missing `or_default` function.

* Fix compilation and simplify code

* Undo change that corrupts benchmark.

* fix clippy

* Update client/service/test/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

remove leftovers!

* Update client/tracing/src/logging/directives.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/fork-tree/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* added needed ref

* Update frame/referenda/src/benchmarking.rs

* Simplify byte-vec creation

* let's just not overlap the ranges

* Correction

* cargo fmt

* Update utils/frame/benchmarking-cli/src/shared/stats.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
Falco Hirschenberger
2022-04-30 23:28:27 +02:00
committed by GitHub
parent a990473cf9
commit b581604aa7
368 changed files with 1927 additions and 2236 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ pub fn get<T: Decode + Sized>(child_info: &ChildInfo, key: &[u8]) -> Option<T> {
/// Return the value of the item in storage under `key`, or the type's default if there is no
/// explicit entry.
pub fn get_or_default<T: Decode + Sized + Default>(child_info: &ChildInfo, key: &[u8]) -> T {
get(child_info, key).unwrap_or_else(Default::default)
get(child_info, key).unwrap_or_default()
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no
@@ -90,7 +90,7 @@ pub fn take<T: Decode + Sized>(child_info: &ChildInfo, key: &[u8]) -> Option<T>
/// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
/// the default for its type.
pub fn take_or_default<T: Codec + Sized + Default>(child_info: &ChildInfo, key: &[u8]) -> T {
take(child_info, key).unwrap_or_else(Default::default)
take(child_info, key).unwrap_or_default()
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no
@@ -461,7 +461,7 @@ where
},
};
let mut key2_material = G::Hasher2::reverse(&key_material);
let mut key2_material = G::Hasher2::reverse(key_material);
let key2 = match K2::decode(&mut key2_material) {
Ok(key2) => key2,
Err(_) => {
+13 -13
View File
@@ -28,7 +28,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get(&hash(key).as_ref())
unhashed::get(hash(key).as_ref())
}
/// Return the value of the item in storage under `key`, or the type's default if there is no
@@ -39,7 +39,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or_default(&hash(key).as_ref())
unhashed::get_or_default(hash(key).as_ref())
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no
@@ -50,7 +50,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or(&hash(key).as_ref(), default_value)
unhashed::get_or(hash(key).as_ref(), default_value)
}
/// Return the value of the item in storage under `key`, or `default_value()` if there is no
@@ -62,7 +62,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_or_else(&hash(key).as_ref(), default_value)
unhashed::get_or_else(hash(key).as_ref(), default_value)
}
/// Put `value` in storage under `key`.
@@ -72,7 +72,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::put(&hash(key).as_ref(), value)
unhashed::put(hash(key).as_ref(), value)
}
/// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
@@ -82,7 +82,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take(&hash(key).as_ref())
unhashed::take(hash(key).as_ref())
}
/// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
@@ -93,7 +93,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or_default(&hash(key).as_ref())
unhashed::take_or_default(hash(key).as_ref())
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no
@@ -104,7 +104,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or(&hash(key).as_ref(), default_value)
unhashed::take_or(hash(key).as_ref(), default_value)
}
/// Return the value of the item in storage under `key`, or `default_value()` if there is no
@@ -116,7 +116,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::take_or_else(&hash(key).as_ref(), default_value)
unhashed::take_or_else(hash(key).as_ref(), default_value)
}
/// Check to see if `key` has an explicit entry in storage.
@@ -125,7 +125,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::exists(&hash(key).as_ref())
unhashed::exists(hash(key).as_ref())
}
/// Ensure `key` has no explicit entry in storage.
@@ -134,7 +134,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::kill(&hash(key).as_ref())
unhashed::kill(hash(key).as_ref())
}
/// Get a Vec of bytes from storage.
@@ -143,7 +143,7 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::get_raw(&hash(key).as_ref())
unhashed::get_raw(hash(key).as_ref())
}
/// Put a raw byte slice into storage.
@@ -152,5 +152,5 @@ where
HashFn: Fn(&[u8]) -> R,
R: AsRef<[u8]>,
{
unhashed::put_raw(&hash(key).as_ref(), value)
unhashed::put_raw(hash(key).as_ref(), value)
}
+1 -1
View File
@@ -1038,7 +1038,7 @@ impl<T> Iterator for ChildTriePrefixIterator<T> {
Some(self.previous_key.clone())
} else {
sp_io::default_child_storage::next_key(
&self.child_info.storage_key(),
self.child_info.storage_key(),
&self.previous_key,
)
.filter(|n| n.starts_with(&self.prefix))
@@ -217,8 +217,7 @@ where
/// Take the value under a key.
pub fn take<KeyArg: EncodeLike<Key> + Clone>(key: KeyArg) -> QueryKind::Query {
let removed_value =
<Self as MapWrapper>::Map::mutate_exists(key, |value| core::mem::replace(value, None));
let removed_value = <Self as MapWrapper>::Map::mutate_exists(key, |value| value.take());
if removed_value.is_some() {
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
}
@@ -429,7 +428,7 @@ where
if cfg!(feature = "no-metadata-docs") {
vec![]
} else {
vec![&"Counter for the related counted storage map"]
vec!["Counter for the related counted storage map"]
},
entries,
);
@@ -481,7 +481,7 @@ where
modifier: QueryKind::METADATA,
ty: StorageEntryType::Map {
key: scale_info::meta_type::<Key::Key>(),
hashers: Key::HASHER_METADATA.iter().cloned().collect(),
hashers: Key::HASHER_METADATA.to_vec(),
value: scale_info::meta_type::<Value>(),
},
default: OnEmpty::get().encode(),
@@ -38,7 +38,7 @@ pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
/// Return the value of the item in storage under `key`, or the type's default if there is no
/// explicit entry.
pub fn get_or_default<T: Decode + Sized + Default>(key: &[u8]) -> T {
get(key).unwrap_or_else(Default::default)
get(key).unwrap_or_default()
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no
@@ -70,7 +70,7 @@ pub fn take<T: Decode + Sized>(key: &[u8]) -> Option<T> {
/// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
/// the default for its type.
pub fn take_or_default<T: Decode + Sized + Default>(key: &[u8]) -> T {
take(key).unwrap_or_else(Default::default)
take(key).unwrap_or_default()
}
/// Return the value of the item in storage under `key`, or `default_value` if there is no