mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Make clippy _a little_ more annoying (#10570)
* Clippy: +complexity * Update client/cli/src/arg_enums.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update bin/node/inspect/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update primitives/keystore/src/testing.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/elections/src/lib.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update primitives/npos-elections/fuzzer/src/reduce.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Incorporating feedback * No need for Ok * Additional * Needed slice * Wigy's suggestions on less derefs * fix count * reverting changes brought in by option_map_unit_fn * add --all-targets Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
@@ -704,11 +704,11 @@ impl StorageDef {
|
||||
})
|
||||
.unwrap_or(Some(QueryKind::OptionQuery)); // This value must match the default generic.
|
||||
|
||||
if query_kind.is_none() && getter.is_some() {
|
||||
if let (None, Some(getter)) = (query_kind.as_ref(), getter.as_ref()) {
|
||||
let msg = "Invalid pallet::storage, cannot generate getter because QueryKind is not \
|
||||
identifiable. QueryKind must be `OptionQuery`, `ValueQuery`, or default one to be \
|
||||
identifiable.";
|
||||
return Err(syn::Error::new(getter.unwrap().span(), msg))
|
||||
return Err(syn::Error::new(getter.span(), msg))
|
||||
}
|
||||
|
||||
Ok(StorageDef {
|
||||
|
||||
@@ -1546,7 +1546,7 @@ macro_rules! decl_module {
|
||||
<Self as $crate::traits::GetStorageVersion>::current_storage_version(),
|
||||
);
|
||||
|
||||
(|| { $( $impl )* })()
|
||||
{ $( $impl )* }
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
|
||||
@@ -181,8 +181,8 @@ pub fn storage_iter_with_suffix<T: Decode + Sized>(
|
||||
prefix.extend_from_slice(&storage_prefix);
|
||||
prefix.extend_from_slice(suffix);
|
||||
let previous_key = prefix.clone();
|
||||
let closure = |raw_key_without_prefix: &[u8], raw_value: &[u8]| {
|
||||
let value = T::decode(&mut &raw_value[..])?;
|
||||
let closure = |raw_key_without_prefix: &[u8], mut raw_value: &[u8]| {
|
||||
let value = T::decode(&mut raw_value)?;
|
||||
Ok((raw_key_without_prefix.to_vec(), value))
|
||||
};
|
||||
|
||||
@@ -213,10 +213,10 @@ pub fn storage_key_iter_with_suffix<
|
||||
prefix.extend_from_slice(&storage_prefix);
|
||||
prefix.extend_from_slice(suffix);
|
||||
let previous_key = prefix.clone();
|
||||
let closure = |raw_key_without_prefix: &[u8], raw_value: &[u8]| {
|
||||
let closure = |raw_key_without_prefix: &[u8], mut raw_value: &[u8]| {
|
||||
let mut key_material = H::reverse(raw_key_without_prefix);
|
||||
let key = K::decode(&mut key_material)?;
|
||||
let value = T::decode(&mut &raw_value[..])?;
|
||||
let value = T::decode(&mut raw_value)?;
|
||||
Ok((key, value))
|
||||
};
|
||||
PrefixIterator { prefix, previous_key, drain: false, closure, phantom: Default::default() }
|
||||
|
||||
@@ -1018,8 +1018,8 @@ impl<T: Decode + Sized> ChildTriePrefixIterator<(Vec<u8>, T)> {
|
||||
pub fn with_prefix(child_info: &ChildInfo, prefix: &[u8]) -> Self {
|
||||
let prefix = prefix.to_vec();
|
||||
let previous_key = prefix.clone();
|
||||
let closure = |raw_key_without_prefix: &[u8], raw_value: &[u8]| {
|
||||
let value = T::decode(&mut &raw_value[..])?;
|
||||
let closure = |raw_key_without_prefix: &[u8], mut raw_value: &[u8]| {
|
||||
let value = T::decode(&mut raw_value)?;
|
||||
Ok((raw_key_without_prefix.to_vec(), value))
|
||||
};
|
||||
|
||||
@@ -1045,10 +1045,10 @@ impl<K: Decode + Sized, T: Decode + Sized> ChildTriePrefixIterator<(K, T)> {
|
||||
) -> Self {
|
||||
let prefix = prefix.to_vec();
|
||||
let previous_key = prefix.clone();
|
||||
let closure = |raw_key_without_prefix: &[u8], raw_value: &[u8]| {
|
||||
let closure = |raw_key_without_prefix: &[u8], mut raw_value: &[u8]| {
|
||||
let mut key_material = H::reverse(raw_key_without_prefix);
|
||||
let key = K::decode(&mut key_material)?;
|
||||
let value = T::decode(&mut &raw_value[..])?;
|
||||
let value = T::decode(&mut raw_value)?;
|
||||
Ok((key, value))
|
||||
};
|
||||
|
||||
|
||||
@@ -30,15 +30,9 @@ pub mod pallet {
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[cfg_attr(feature = "std", derive(Default))]
|
||||
pub struct GenesisConfig {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl Default for GenesisConfig {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig {
|
||||
fn build(&self) {}
|
||||
|
||||
@@ -40,5 +40,5 @@ impl Config for Test {}
|
||||
|
||||
#[test]
|
||||
fn init_genesis_config() {
|
||||
GenesisConfig::<Test> { t: Default::default() };
|
||||
GenesisConfig::<Test>::default();
|
||||
}
|
||||
|
||||
@@ -184,7 +184,9 @@ frame_support::construct_runtime!(
|
||||
|
||||
#[test]
|
||||
fn create_genesis_config() {
|
||||
GenesisConfig {
|
||||
let config = GenesisConfig {
|
||||
module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true },
|
||||
};
|
||||
assert_eq!(config.module.request_life_time, 0);
|
||||
assert!(config.module.enable_storage_role);
|
||||
}
|
||||
|
||||
@@ -881,7 +881,7 @@ fn pallet_expand_deposit_event() {
|
||||
|
||||
#[test]
|
||||
fn pallet_new_call_variant() {
|
||||
Call::Example(pallet::Call::new_call_variant_foo(3, 4));
|
||||
pallet::Call::<Runtime>::new_call_variant_foo(3, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user