style: Migrate to stable-only rustfmt configuration

- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml
- Removed features: imports_granularity, wrap_comments, comment_width,
  reorder_impl_items, spaces_around_ranges, binop_separator,
  match_arm_blocks, trailing_semicolon, trailing_comma
- Format all 898 affected files with stable rustfmt
- Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
2025-12-22 17:12:58 +03:00
parent 65b7f5e640
commit 4c8f281051
898 changed files with 8671 additions and 6432 deletions
@@ -414,11 +414,12 @@ fn parse_call_def(item_fn: &ItemFn) -> Result<(usize, BenchmarkCallDef)> {
Ok(match &call_defs[..] {
[(i, call_def)] => (*i, call_def.clone()), // = 1
[] => return missing_call(item_fn),
_ =>
_ => {
return Err(Error::new(
call_defs[1].1.attr_span(),
"Only one #[extrinsic_call] or #[block] attribute is allowed per benchmark.",
)),
))
},
})
}
@@ -432,7 +433,9 @@ impl BenchmarkDef {
let (verify_stmts, last_stmt) = match item_fn.sig.output {
ReturnType::Default =>
// no return type, last_stmt should be None
(Vec::from(&item_fn.block.stmts[(i + 1)..item_fn.block.stmts.len()]), None),
{
(Vec::from(&item_fn.block.stmts[(i + 1)..item_fn.block.stmts.len()]), None)
},
ReturnType::Type(_, _) => {
// defined return type, last_stmt should be Result<(), BenchmarkError>
// compatible and should not be included in verify_stmts
@@ -481,12 +484,13 @@ pub fn benchmarks(
let module: ItemMod = syn::parse(tokens)?;
let mod_span = module.span();
let where_clause = match syn::parse::<Nothing>(attrs.clone()) {
Ok(_) =>
Ok(_) => {
if instance {
quote!(T: Config<I>, I: 'static)
} else {
quote!(T: Config)
},
}
},
Err(_) => {
let mut where_clause_predicates = syn::parse::<WhereClause>(attrs)?.predicates;
@@ -1026,8 +1030,9 @@ fn expand_benchmark(
},
)
},
BenchmarkCallDef::Block { block, attr_span: _ } =>
(quote!(), quote!(#block), quote!(#block)),
BenchmarkCallDef::Block { block, attr_span: _ } => {
(quote!(), quote!(#block), quote!(#block))
},
};
let vis = benchmark_def.fn_vis;
@@ -96,22 +96,25 @@ impl Parse for RuntimeDeclaration {
let pallets_token = pallets.token;
match convert_pallets(pallets.content.inner.into_iter().collect())? {
PalletsConversion::Implicit(pallets) =>
Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { pallets })),
PalletsConversion::Explicit(pallets) =>
PalletsConversion::Implicit(pallets) => {
Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { pallets }))
},
PalletsConversion::Explicit(pallets) => {
Ok(RuntimeDeclaration::Explicit(ExplicitRuntimeDeclaration {
name,
where_section,
pallets,
pallets_token,
})),
PalletsConversion::ExplicitExpanded(pallets) =>
}))
},
PalletsConversion::ExplicitExpanded(pallets) => {
Ok(RuntimeDeclaration::ExplicitExpanded(ExplicitRuntimeDeclaration {
name,
where_section,
pallets,
pallets_token,
})),
}))
},
}
}
}
@@ -234,13 +237,13 @@ impl Parse for PalletDeclaration {
let res = Some(input.parse()?);
let _: Token![>] = input.parse()?;
res
} else if !(input.peek(Token![::]) && input.peek3(token::Brace)) &&
!input.peek(keyword::expanded) &&
!input.peek(keyword::exclude_parts) &&
!input.peek(keyword::use_parts) &&
!input.peek(Token![=]) &&
!input.peek(Token![,]) &&
!input.is_empty()
} else if !(input.peek(Token![::]) && input.peek3(token::Brace))
&& !input.peek(keyword::expanded)
&& !input.peek(keyword::exclude_parts)
&& !input.peek(keyword::use_parts)
&& !input.peek(Token![=])
&& !input.peek(Token![,])
&& !input.is_empty()
{
return Err(input.error(
"Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,`",
@@ -264,11 +267,11 @@ impl Parse for PalletDeclaration {
let mut parts = parse_pallet_parts(input)?;
parts.extend(extra_parts.into_iter());
Some(parts)
} else if !input.peek(keyword::exclude_parts) &&
!input.peek(keyword::use_parts) &&
!input.peek(Token![=]) &&
!input.peek(Token![,]) &&
!input.is_empty()
} else if !input.peek(keyword::exclude_parts)
&& !input.peek(keyword::use_parts)
&& !input.peek(Token![=])
&& !input.peek(Token![,])
&& !input.is_empty()
{
return Err(input.error(
"Unexpected tokens, expected one of `::{`, `exclude_parts`, `use_parts`, `=`, `,`",
@@ -342,10 +345,10 @@ impl Parse for PalletPath {
PalletPath { inner: Path { leading_colon: None, segments: Punctuated::new() } };
let lookahead = input.lookahead1();
if lookahead.peek(Token![crate]) ||
lookahead.peek(Token![self]) ||
lookahead.peek(Token![super]) ||
lookahead.peek(Ident)
if lookahead.peek(Token![crate])
|| lookahead.peek(Token![self])
|| lookahead.peek(Token![super])
|| lookahead.peek(Ident)
{
let ident = input.call(Ident::parse_any)?;
res.inner.segments.push(ident.into());
@@ -720,7 +723,7 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
// Check parts are correctly specified
match &pezpallet.specified_parts {
SpecifiedParts::Exclude(parts) | SpecifiedParts::Use(parts) =>
SpecifiedParts::Exclude(parts) | SpecifiedParts::Use(parts) => {
for part in parts {
if !available_parts.contains(part.keyword.name()) {
let msg = format!(
@@ -738,7 +741,8 @@ fn convert_pallets(pallets: Vec<PalletDeclaration>) -> syn::Result<PalletsConver
);
return Err(syn::Error::new(part.keyword.span(), msg));
}
},
}
},
SpecifiedParts::All => (),
}
@@ -78,7 +78,9 @@ impl syn::parse::Parse for DeriveImplAttrArgs {
(default_impl_path, Some(args.clone()))
},
Some(PathSegment { arguments: PathArguments::None, .. }) => (default_impl_path, None),
_ => return Err(syn::Error::new(default_impl_path.span(), "Invalid default impl path")),
_ => {
return Err(syn::Error::new(default_impl_path.span(), "Invalid default impl path"))
},
};
let lookahead = input.lookahead1();
@@ -228,13 +230,14 @@ fn compute_disambiguation_path(
) -> Result<Path> {
match (disambiguation_path, foreign_impl.clone().trait_) {
(Some(disambiguation_path), _) => Ok(disambiguation_path),
(None, Some((_, foreign_impl_path, _))) =>
(None, Some((_, foreign_impl_path, _))) => {
if default_impl_path.segments.len() > 1 {
let scope = default_impl_path.segments.first();
Ok(parse_quote!(#scope :: #foreign_impl_path))
} else {
Ok(foreign_impl_path)
},
}
},
_ => Err(syn::Error::new(
default_impl_path.span(),
"Impl statement must have a defined type being implemented \
@@ -820,15 +820,15 @@ pub fn register_default_impl(attrs: TokenStream, tokens: TokenStream) -> TokenSt
pub fn inject_runtime_type(_: TokenStream, tokens: TokenStream) -> TokenStream {
let item = tokens.clone();
let item = syn::parse_macro_input!(item as TraitItemType);
if item.ident != "RuntimeCall" &&
item.ident != "RuntimeEvent" &&
item.ident != "RuntimeTask" &&
item.ident != "RuntimeViewFunction" &&
item.ident != "RuntimeOrigin" &&
item.ident != "RuntimeHoldReason" &&
item.ident != "RuntimeFreezeReason" &&
item.ident != "RuntimeParameters" &&
item.ident != "PalletInfo"
if item.ident != "RuntimeCall"
&& item.ident != "RuntimeEvent"
&& item.ident != "RuntimeTask"
&& item.ident != "RuntimeViewFunction"
&& item.ident != "RuntimeOrigin"
&& item.ident != "RuntimeHoldReason"
&& item.ident != "RuntimeFreezeReason"
&& item.ident != "RuntimeParameters"
&& item.ident != "PalletInfo"
{
return syn::Error::new_spanned(
item,
@@ -138,13 +138,14 @@ pub fn derive_default_no_bound(input: proc_macro::TokenStream) -> proc_macro::To
},
}
},
Data::Union(union_) =>
Data::Union(union_) => {
return syn::Error::new_spanned(
union_.union_token,
"Union type not supported by `derive(DefaultNoBound)`",
)
.to_compile_error()
.into(),
.into()
},
};
quote!(
@@ -27,9 +27,9 @@ pub fn derive_partial_ord_no_bound(input: proc_macro::TokenStream) -> proc_macro
let name = &input.ident;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let impl_ = match input.data {
syn::Data::Struct(struct_) =>
match struct_.fields {
let impl_ =
match input.data {
syn::Data::Struct(struct_) => match struct_.fields {
syn::Fields::Named(named) => {
let fields =
named.named.iter().map(|i| &i.ident).map(
@@ -66,15 +66,15 @@ pub fn derive_partial_ord_no_bound(input: proc_macro::TokenStream) -> proc_macro
quote::quote!(Some(core::cmp::Ordering::Equal))
},
},
syn::Data::Enum(_) => {
let msg = "Enum type not supported by `derive(PartialOrdNoBound)`";
return syn::Error::new(input.span(), msg).to_compile_error().into();
},
syn::Data::Union(_) => {
let msg = "Union type not supported by `derive(PartialOrdNoBound)`";
return syn::Error::new(input.span(), msg).to_compile_error().into();
},
};
syn::Data::Enum(_) => {
let msg = "Enum type not supported by `derive(PartialOrdNoBound)`";
return syn::Error::new(input.span(), msg).to_compile_error().into();
},
syn::Data::Union(_) => {
let msg = "Union type not supported by `derive(PartialOrdNoBound)`";
return syn::Error::new(input.span(), msg).to_compile_error().into();
},
};
quote::quote!(
const _: () = {
@@ -50,10 +50,12 @@ fn parse_doc_value(attr: &Attribute) -> syn::Result<Option<DocMetaValue>> {
match &meta.value {
syn::Expr::Lit(lit) => Ok(Some(DocMetaValue::Lit(lit.lit.clone()))),
syn::Expr::Macro(mac) if mac.mac.path.is_ident("include_str") =>
Ok(Some(DocMetaValue::Path(mac.mac.parse_body()?))),
_ =>
Err(syn::Error::new(attr.span(), "Expected `= \"docs\"` or `= include_str!(\"PATH\")`")),
syn::Expr::Macro(mac) if mac.mac.path.is_ident("include_str") => {
Ok(Some(DocMetaValue::Path(mac.mac.parse_body()?)))
},
_ => {
Err(syn::Error::new(attr.span(), "Expected `= \"docs\"` or `= include_str!(\"PATH\")`"))
},
}
}
@@ -83,9 +83,9 @@ pub fn expand_genesis_config(def: &mut Def) -> proc_macro2::TokenStream {
let serde_crate = format!("{}::__private::serde", pezframe_support.to_token_stream());
match genesis_config_item {
syn::Item::Enum(syn::ItemEnum { attrs, .. }) |
syn::Item::Struct(syn::ItemStruct { attrs, .. }) |
syn::Item::Type(syn::ItemType { attrs, .. }) => {
syn::Item::Enum(syn::ItemEnum { attrs, .. })
| syn::Item::Struct(syn::ItemStruct { attrs, .. })
| syn::Item::Type(syn::ItemType { attrs, .. }) => {
if get_doc_literals(attrs).is_empty() {
attrs.push(syn::parse_quote!(
#[doc = r"
@@ -198,8 +198,8 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
let on_empty = on_empty.unwrap_or_else(|| default_on_empty(value));
args.args.push(syn::GenericArgument::Type(on_empty));
},
StorageGenerics::Map { hasher, key, value, query_kind, on_empty, max_values } |
StorageGenerics::CountedMap {
StorageGenerics::Map { hasher, key, value, query_kind, on_empty, max_values }
| StorageGenerics::CountedMap {
hasher,
key,
value,
@@ -241,8 +241,8 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
let max_values = max_values.unwrap_or_else(|| default_max_values.clone());
args.args.push(syn::GenericArgument::Type(max_values));
},
StorageGenerics::NMap { keygen, value, query_kind, on_empty, max_values } |
StorageGenerics::CountedNMap {
StorageGenerics::NMap { keygen, value, query_kind, on_empty, max_values }
| StorageGenerics::CountedNMap {
keygen,
value,
query_kind,
@@ -295,8 +295,8 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
// Here, we only need to check if OnEmpty is *not* specified, and if so, then we have to
// generate a default OnEmpty struct for it.
if on_empty_idx >= args.args.len() &&
matches!(storage_def.query_kind.as_ref(), Some(QueryKind::ResultQuery(_, _)))
if on_empty_idx >= args.args.len()
&& matches!(storage_def.query_kind.as_ref(), Some(QueryKind::ResultQuery(_, _)))
{
let value_ty = match args.args[value_idx].clone() {
syn::GenericArgument::Type(ty) => ty,
@@ -21,8 +21,9 @@ use syn::spanned::Spanned;
pub fn expand_view_functions(def: &Def) -> TokenStream {
let (span, where_clause, view_fns) = match def.view_functions.as_ref() {
Some(view_fns) =>
(view_fns.attr_span, view_fns.where_clause.clone(), view_fns.view_functions.clone()),
Some(view_fns) => {
(view_fns.attr_span, view_fns.where_clause.clone(), view_fns.view_functions.clone())
},
None => (def.item.span(), def.config.where_clause.clone(), Vec::new()),
};
@@ -259,7 +259,10 @@ impl CallDef {
let item_impl = if let syn::Item::Impl(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::call, expected item impl"));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::call, expected item impl",
));
};
crate::deprecation::prevent_deprecation_attr_on_outer_enum(&item_impl.attrs)?;
@@ -406,11 +409,12 @@ impl CallDef {
let final_index = match call_index {
Some(i) => i,
None =>
None => {
last_index.map_or(Some(0), |idx| idx.checked_add(1)).ok_or_else(|| {
let msg = "Call index doesn't fit into u8, index is 256";
syn::Error::new(method.sig.span(), msg)
})?,
})?
},
};
last_index = Some(final_index);
@@ -112,11 +112,12 @@ impl CompositeDef {
// a fixed variant count.
for variant in &item.variants {
match variant.fields {
syn::Fields::Named(_) | syn::Fields::Unnamed(_) =>
syn::Fields::Named(_) | syn::Fields::Unnamed(_) => {
return Err(syn::Error::new(
variant.ident.span(),
"The composite enum does not support variants with fields!",
)),
))
},
syn::Fields::Unit => (),
}
}
@@ -309,16 +309,22 @@ fn has_expected_system_config(path: syn::Path, pezframe_system: &syn::Path) -> b
(true, false) =>
// We can't use the path to `pezframe_system` from `frame` if `pezframe_system` is not
// being in scope through `frame`.
return false,
{
return false
},
(false, true) =>
// We know that the only valid pezframe_system path is one that is `pezframe_system`, as
// `frame` re-exports it as such.
{
syn::parse2::<syn::Path>(quote::quote!(pezframe_system))
.expect("is a valid path; qed"),
.expect("is a valid path; qed")
},
(_, _) =>
// They are either both `pezframe_system` or both
// `pezkuwi_sdk_frame::xyz::pezframe_system`.
pezframe_system.clone(),
{
pezframe_system.clone()
},
};
expected_system_config
@@ -331,8 +337,8 @@ fn has_expected_system_config(path: syn::Path, pezframe_system: &syn::Path) -> b
.segments
.into_iter()
.map(|ps| ps.ident)
.collect::<Vec<_>>() ==
path.segments.into_iter().map(|ps| ps.ident).collect::<Vec<_>>()
.collect::<Vec<_>>()
== path.segments.into_iter().map(|ps| ps.ident).collect::<Vec<_>>()
}
/// Replace ident `Self` by `T`
@@ -340,10 +346,12 @@ pub fn replace_self_by_t(input: proc_macro2::TokenStream) -> proc_macro2::TokenS
input
.into_iter()
.map(|token_tree| match token_tree {
proc_macro2::TokenTree::Group(group) =>
proc_macro2::Group::new(group.delimiter(), replace_self_by_t(group.stream())).into(),
proc_macro2::TokenTree::Ident(ident) if ident == "Self" =>
proc_macro2::Ident::new("T", ident.span()).into(),
proc_macro2::TokenTree::Group(group) => {
proc_macro2::Group::new(group.delimiter(), replace_self_by_t(group.stream())).into()
},
proc_macro2::TokenTree::Ident(ident) if ident == "Self" => {
proc_macro2::Ident::new("T", ident.span()).into()
},
other => other,
})
.collect()
@@ -101,8 +101,8 @@ impl ErrorDef {
};
match &variant.discriminant {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
None
| Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
@@ -285,12 +285,13 @@ impl Def {
// ensure that if `task_enum` is specified, `tasks` is also specified
match (&task_enum, &tasks) {
(Some(_), None) =>
(Some(_), None) => {
return Err(syn::Error::new(
*item_span,
"Missing `#[pezpallet::tasks_experimental]` impl",
)),
(None, Some(tasks)) =>
))
},
(None, Some(tasks)) => {
if tasks.tasks_attr.is_none() {
return Err(syn::Error::new(
tasks.item_impl.impl_token.span(),
@@ -298,7 +299,8 @@ impl Def {
task enum has been omitted",
));
} else {
},
}
},
_ => (),
}
@@ -52,10 +52,10 @@ pub enum PalletStorageAttr {
impl PalletStorageAttr {
fn attr_span(&self) -> proc_macro2::Span {
match self {
Self::Getter(_, span) |
Self::StorageName(_, span) |
Self::Unbounded(span) |
Self::WhitelistStorage(span) => *span,
Self::Getter(_, span)
| Self::StorageName(_, span)
| Self::Unbounded(span)
| Self::WhitelistStorage(span) => *span,
Self::DisableTryDecodeStorage(span) => *span,
}
}
@@ -124,17 +124,20 @@ impl PalletStorageAttrInfo {
for attr in attrs {
match attr {
PalletStorageAttr::Getter(ident, ..) if getter.is_none() => getter = Some(ident),
PalletStorageAttr::StorageName(name, ..) if rename_as.is_none() =>
rename_as = Some(name),
PalletStorageAttr::StorageName(name, ..) if rename_as.is_none() => {
rename_as = Some(name)
},
PalletStorageAttr::Unbounded(..) if !unbounded => unbounded = true,
PalletStorageAttr::WhitelistStorage(..) if !whitelisted => whitelisted = true,
PalletStorageAttr::DisableTryDecodeStorage(..) if !disable_try_decode_storage =>
disable_try_decode_storage = true,
attr =>
PalletStorageAttr::DisableTryDecodeStorage(..) if !disable_try_decode_storage => {
disable_try_decode_storage = true
},
attr => {
return Err(syn::Error::new(
attr.attr_span(),
"Invalid attribute: Duplicate attribute",
)),
))
},
}
}
@@ -269,10 +272,12 @@ impl StorageGenerics {
Self::Map { value, key, .. } => Metadata::Map { value, key },
Self::CountedMap { value, key, .. } => Metadata::CountedMap { value, key },
Self::Value { value, .. } => Metadata::Value { value },
Self::NMap { keygen, value, .. } =>
Metadata::NMap { keys: collect_keys(&keygen)?, keygen, value },
Self::CountedNMap { keygen, value, .. } =>
Metadata::CountedNMap { keys: collect_keys(&keygen)?, keygen, value },
Self::NMap { keygen, value, .. } => {
Metadata::NMap { keys: collect_keys(&keygen)?, keygen, value }
},
Self::CountedNMap { keygen, value, .. } => {
Metadata::CountedNMap { keys: collect_keys(&keygen)?, keygen, value }
},
};
Ok(res)
@@ -281,12 +286,12 @@ impl StorageGenerics {
/// Return the query kind from the defined generics
fn query_kind(&self) -> Option<syn::Type> {
match &self {
Self::DoubleMap { query_kind, .. } |
Self::Map { query_kind, .. } |
Self::CountedMap { query_kind, .. } |
Self::Value { query_kind, .. } |
Self::NMap { query_kind, .. } |
Self::CountedNMap { query_kind, .. } => query_kind.clone(),
Self::DoubleMap { query_kind, .. }
| Self::Map { query_kind, .. }
| Self::CountedMap { query_kind, .. }
| Self::Value { query_kind, .. }
| Self::NMap { query_kind, .. }
| Self::CountedNMap { query_kind, .. } => query_kind.clone(),
}
}
}
@@ -328,8 +333,8 @@ fn check_generics(
};
for (gen_name, gen_binding) in map {
if !mandatory_generics.contains(&gen_name.as_str()) &&
!optional_generics.contains(&gen_name.as_str())
if !mandatory_generics.contains(&gen_name.as_str())
&& !optional_generics.contains(&gen_name.as_str())
{
let msg = format!(
"Invalid pezpallet::storage, Unexpected generic `{}` for `{}`. {}",
@@ -600,8 +605,9 @@ fn process_unnamed_generics(
};
let res = match storage {
StorageKind::Value =>
(None, Metadata::Value { value: retrieve_arg(1)? }, retrieve_arg(2).ok(), false),
StorageKind::Value => {
(None, Metadata::Value { value: retrieve_arg(1)? }, retrieve_arg(2).ok(), false)
},
StorageKind::Map => (
None,
Metadata::Map { key: retrieve_arg(2)?, value: retrieve_arg(3)? },
@@ -841,16 +847,22 @@ impl StorageDef {
.segments
.last()
.map_or(false, |s| s.ident == "OptionQuery") =>
return Ok(Some(QueryKind::OptionQuery)),
{
return Ok(Some(QueryKind::OptionQuery))
},
Type::Path(TypePath { path: Path { segments, .. }, .. })
if segments.last().map_or(false, |s| s.ident == "ResultQuery") =>
{
segments
.last()
.expect("segments is checked to have the last value; qed")
.clone(),
.clone()
},
Type::Path(path)
if path.path.segments.last().map_or(false, |s| s.ident == "ValueQuery") =>
return Ok(Some(QueryKind::ValueQuery)),
{
return Ok(Some(QueryKind::ValueQuery))
},
_ => return Ok(None),
};
@@ -415,11 +415,12 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskIndexAttr {
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskIndex(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
_ => {
return Err(Error::new(
value.span(),
format!("`{:?}` cannot be converted to a `TaskIndexAttr`", value.meta),
)),
))
},
}
}
}
@@ -433,11 +434,12 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskConditionAttr {
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskCondition(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
_ => {
return Err(Error::new(
value.span(),
format!("`{:?}` cannot be converted to a `TaskConditionAttr`", value.meta),
)),
))
},
}
}
}
@@ -451,11 +453,12 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskWeightAttr {
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskWeight(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
_ => {
return Err(Error::new(
value.span(),
format!("`{:?}` cannot be converted to a `TaskWeightAttr`", value.meta),
)),
))
},
}
}
}
@@ -469,11 +472,12 @@ impl TryFrom<PalletTaskAttr<TaskAttrMeta>> for TaskListAttr {
let colons = value.colons;
match value.meta {
TaskAttrMeta::TaskList(meta) => parse2(quote!(#pound[#pezpallet #colons #meta])),
_ =>
_ => {
return Err(Error::new(
value.span(),
format!("`{:?}` cannot be converted to a `TaskListAttr`", value.meta),
)),
))
},
}
}
}
@@ -534,12 +538,12 @@ fn partition_task_attrs(item: &ImplItemFn) -> (Vec<syn::Attribute>, Vec<syn::Att
};
// N.B: the `PartialEq` impl between `Ident` and `&str` is more efficient than
// parsing and makes no stack or heap allocations
prefix.ident == "pezpallet" &&
(suffix.ident == "tasks_experimental" ||
suffix.ident == "task_list" ||
suffix.ident == "task_condition" ||
suffix.ident == "task_weight" ||
suffix.ident == "task_index")
prefix.ident == "pezpallet"
&& (suffix.ident == "tasks_experimental"
|| suffix.ident == "task_list"
|| suffix.ident == "task_condition"
|| suffix.ident == "task_weight"
|| suffix.ident == "task_index")
})
}
@@ -34,8 +34,8 @@ pub fn derive_pallet_error(input: proc_macro::TokenStream) -> proc_macro::TokenS
let max_encoded_size = match data {
syn::Data::Struct(syn::DataStruct { fields, .. }) => match fields {
syn::Fields::Named(syn::FieldsNamed { named: fields, .. }) |
syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed: fields, .. }) => {
syn::Fields::Named(syn::FieldsNamed { named: fields, .. })
| syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed: fields, .. }) => {
let maybe_field_tys = fields
.iter()
.map(|f| generate_field_types(f, &pezframe_support))
@@ -166,8 +166,8 @@ fn generate_variant_field_types(
}
match &variant.fields {
syn::Fields::Named(syn::FieldsNamed { named: fields, .. }) |
syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed: fields, .. }) => {
syn::Fields::Named(syn::FieldsNamed { named: fields, .. })
| syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed: fields, .. }) => {
let field_tys = fields
.iter()
.map(|field| generate_field_types(field, scrate))
@@ -102,8 +102,9 @@ fn construct_runtime_implicit_to_explicit(
let runtime_param = &pezpallet.runtime_param;
let pezpallet_segment_and_instance =
match (&pezpallet.pezpallet_segment, &pezpallet.instance) {
(Some(segment), Some(instance)) =>
quote::quote!(::#segment<#runtime_param, #instance>),
(Some(segment), Some(instance)) => {
quote::quote!(::#segment<#runtime_param, #instance>)
},
(Some(segment), None) => quote::quote!(::#segment<#runtime_param>),
(None, Some(instance)) => quote::quote!(<#instance>),
(None, None) => quote::quote!(),
@@ -228,8 +228,8 @@ impl StorageType {
>;
}
},
Self::CountedMap { value_ty, query_type, hasher_ty, key_ty, .. } |
Self::Map { value_ty, query_type, hasher_ty, key_ty, .. } => {
Self::CountedMap { value_ty, query_type, hasher_ty, key_ty, .. }
| Self::Map { value_ty, query_type, hasher_ty, key_ty, .. } => {
let query_type = query_type.as_ref().map(|(c, t)| quote!(#c #t));
let map_type = Ident::new(
match self {
@@ -294,11 +294,11 @@ impl StorageType {
/// The prefix for this storage type.
fn prefix(&self) -> &Type {
match self {
Self::Value { prefix, .. } |
Self::Map { prefix, .. } |
Self::CountedMap { prefix, .. } |
Self::NMap { prefix, .. } |
Self::DoubleMap { prefix, .. } => prefix,
Self::Value { prefix, .. }
| Self::Map { prefix, .. }
| Self::CountedMap { prefix, .. }
| Self::NMap { prefix, .. }
| Self::DoubleMap { prefix, .. } => prefix,
}
}
}
@@ -550,7 +550,7 @@ fn generate_storage_instance(
.unwrap_or_default();
let (pezpallet_prefix, impl_generics, type_generics) = match prefix_type {
PrefixType::Compatibility =>
PrefixType::Compatibility => {
if !impl_generics_used_by_prefix.is_empty() {
let type_generics = impl_generics_used_by_prefix.iter().map(|g| &g.ident);
let impl_generics = impl_generics_used_by_prefix.iter();
@@ -571,15 +571,17 @@ fn generate_storage_instance(
prefix,
"If there are no generics, the prefix is only allowed to be an identifier.",
));
},
}
},
PrefixType::Verbatim => {
let prefix_str = match prefix.get_ident() {
Some(p) => p.to_string(),
None =>
None => {
return Err(Error::new_spanned(
prefix,
"Prefix type `verbatim` requires that the prefix is an ident.",
)),
))
},
};
(quote!(#prefix_str), quote!(), quote!())
@@ -182,8 +182,9 @@ impl<
match <VersionedPostUpgradeData>::decode_all(&mut &versioned_post_upgrade_data_bytes[..])
.map_err(|_| "VersionedMigration post_upgrade failed to decode PreUpgradeData")?
{
VersionedPostUpgradeData::MigrationExecuted(inner_bytes) =>
Inner::post_upgrade(inner_bytes),
VersionedPostUpgradeData::MigrationExecuted(inner_bytes) => {
Inner::post_upgrade(inner_bytes)
},
VersionedPostUpgradeData::Noop => Ok(()),
}
}
@@ -112,8 +112,9 @@ pub fn take_or_else<T: Codec + Sized, F: FnOnce() -> T>(
/// Check to see if `key` has an explicit entry in storage.
pub fn exists(child_info: &ChildInfo, key: &[u8]) -> bool {
match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::exists(child_info.storage_key(), key),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::exists(child_info.storage_key(), key)
},
}
}
@@ -139,8 +140,9 @@ pub fn exists(child_info: &ChildInfo, key: &[u8]) -> bool {
#[deprecated = "Use `clear_storage` instead"]
pub fn kill_storage(child_info: &ChildInfo, limit: Option<u32>) -> KillStorageResult {
match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::storage_kill(child_info.storage_key(), limit),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::storage_kill(child_info.storage_key(), limit)
},
}
}
@@ -185,8 +187,9 @@ pub fn clear_storage(
// enabled.
// pezsp_io::default_child_storage::storage_kill(prefix, maybe_limit, maybe_cursor)
let r = match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::storage_kill(child_info.storage_key(), maybe_limit),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::storage_kill(child_info.storage_key(), maybe_limit)
},
};
use pezsp_io::KillStorageResult::*;
let (maybe_cursor, backend) = match r {
@@ -208,24 +211,27 @@ pub fn kill(child_info: &ChildInfo, key: &[u8]) {
/// Get a Vec of bytes from storage.
pub fn get_raw(child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>> {
match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::get(child_info.storage_key(), key),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::get(child_info.storage_key(), key)
},
}
}
/// Put a raw byte slice into storage.
pub fn put_raw(child_info: &ChildInfo, key: &[u8], value: &[u8]) {
match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::set(child_info.storage_key(), key, value),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::set(child_info.storage_key(), key, value)
},
}
}
/// Calculate current child root value.
pub fn root(child_info: &ChildInfo, version: StateVersion) -> Vec<u8> {
match child_info.child_type() {
ChildType::ParentKeyId =>
pezsp_io::default_child_storage::root(child_info.storage_key(), version),
ChildType::ParentKeyId => {
pezsp_io::default_child_storage::root(child_info.storage_key(), version)
},
}
}
@@ -189,9 +189,13 @@ mod tests {
);
// do translation.
NumberMap::translate(
|k: u32, v: u64| if k.is_multiple_of(2) { Some(((k as u64) << 32) | v) } else { None },
);
NumberMap::translate(|k: u32, v: u64| {
if k.is_multiple_of(2) {
Some(((k as u64) << 32) | v)
} else {
None
}
});
assert_eq!(
NumberMap::iter().collect::<Vec<_>>(),
@@ -592,7 +592,10 @@ mod tests {
pezsp_io::TestExternalities::default().execute_with(|| {
const BUFFER_SIZE: usize = 300;
// Ensure that the capacity isn't dividable by `300`.
assert!(!STORAGE_INPUT_BUFFER_CAPACITY.is_multiple_of(BUFFER_SIZE), "Please update buffer size");
assert!(
!STORAGE_INPUT_BUFFER_CAPACITY.is_multiple_of(BUFFER_SIZE),
"Please update buffer size"
);
// Create some items where the last item is partially in the inner buffer so that
// we need to fill the buffer to read the entire item.
let data: Vec<Vec<u8>> = (0..=(STORAGE_INPUT_BUFFER_CAPACITY / BUFFER_SIZE))
@@ -640,7 +643,10 @@ mod tests {
const BUFFER_SIZE: usize = 300;
// Ensure that the capacity isn't dividable by `300`.
assert!(!STORAGE_INPUT_BUFFER_CAPACITY.is_multiple_of(BUFFER_SIZE), "Please update buffer size");
assert!(
!STORAGE_INPUT_BUFFER_CAPACITY.is_multiple_of(BUFFER_SIZE),
"Please update buffer size"
);
// Create some items where the last item is partially in the inner buffer so that
// we need to fill the buffer to read the entire item.
let data: Vec<Vec<u8>> = (0..=(STORAGE_INPUT_BUFFER_CAPACITY / BUFFER_SIZE))
@@ -1389,9 +1389,9 @@ mod test {
let _ = A::clear(u32::max_value(), None);
// one of the item has been removed
assert!(
!A::contains_key((2, 20, 200)) &&
!A::contains_key((3, 30, 300)) &&
!A::contains_key((4, 40, 400))
!A::contains_key((2, 20, 200))
&& !A::contains_key((3, 30, 300))
&& !A::contains_key((4, 40, 400))
);
assert_eq!(A::count(), 0);
@@ -261,8 +261,8 @@ pub mod identity {
pub fn eq_platform(&self, other: &Social) -> bool {
matches!(
(&self, &other),
(Social::Twitter { .. }, Social::Twitter { .. }) |
(Social::Github { .. }, Social::Github { .. })
(Social::Twitter { .. }, Social::Twitter { .. })
| (Social::Github { .. }, Social::Github { .. })
)
}
}
@@ -154,8 +154,9 @@ impl<
force: Fortitude,
) -> Self::Balance {
match Criterion::convert(asset) {
Left(()) =>
<Left as fungible::Inspect<AccountId>>::reducible_balance(who, preservation, force),
Left(()) => {
<Left as fungible::Inspect<AccountId>>::reducible_balance(who, preservation, force)
},
Right(a) => <Right as fungibles::Inspect<AccountId>>::reducible_balance(
a,
who,
@@ -171,10 +172,12 @@ impl<
provenance: Provenance,
) -> DepositConsequence {
match Criterion::convert(asset) {
Left(()) =>
<Left as fungible::Inspect<AccountId>>::can_deposit(who, amount, provenance),
Right(a) =>
<Right as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance),
Left(()) => {
<Left as fungible::Inspect<AccountId>>::can_deposit(who, amount, provenance)
},
Right(a) => {
<Right as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance)
},
}
}
fn can_withdraw(
@@ -211,21 +214,24 @@ impl<
force: Fortitude,
) -> Self::Balance {
match Criterion::convert(asset) {
Left(()) =>
Left(()) => {
<Left as fungible::InspectHold<AccountId>>::reducible_total_balance_on_hold(
who, force,
),
Right(a) =>
)
},
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::reducible_total_balance_on_hold(
a, who, force,
),
)
},
}
}
fn hold_available(asset: Self::AssetId, reason: &Self::Reason, who: &AccountId) -> bool {
match Criterion::convert(asset) {
Left(()) => <Left as fungible::InspectHold<AccountId>>::hold_available(reason, who),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::hold_available(a, reason, who),
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::hold_available(a, reason, who)
},
}
}
fn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance {
@@ -241,8 +247,9 @@ impl<
) -> Self::Balance {
match Criterion::convert(asset) {
Left(()) => <Left as fungible::InspectHold<AccountId>>::balance_on_hold(reason, who),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::balance_on_hold(a, reason, who),
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::balance_on_hold(a, reason, who)
},
}
}
fn can_hold(
@@ -253,8 +260,9 @@ impl<
) -> bool {
match Criterion::convert(asset) {
Left(()) => <Left as fungible::InspectHold<AccountId>>::can_hold(reason, who, amount),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount),
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount)
},
}
}
}
@@ -301,10 +309,12 @@ impl<
Self: Sized,
{
match Criterion::convert(dust.0) {
Left(()) =>
<Left as fungible::Unbalanced<AccountId>>::handle_dust(fungible::Dust(dust.1)),
Right(a) =>
<Right as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1)),
Left(()) => {
<Left as fungible::Unbalanced<AccountId>>::handle_dust(fungible::Dust(dust.1))
},
Right(a) => {
<Right as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1))
},
}
}
fn write_balance(
@@ -356,8 +366,9 @@ impl<
precision: Precision,
) -> Result<Self::Balance, DispatchError> {
match Criterion::convert(asset) {
Left(()) =>
<Left as fungible::Unbalanced<AccountId>>::increase_balance(who, amount, precision),
Left(()) => {
<Left as fungible::Unbalanced<AccountId>>::increase_balance(who, amount, precision)
},
Right(a) => <Right as fungibles::Unbalanced<AccountId>>::increase_balance(
a, who, amount, precision,
),
@@ -494,8 +505,9 @@ impl<
preservation: Preservation,
) -> Result<Self::Balance, DispatchError> {
match Criterion::convert(asset) {
Left(()) =>
<Left as fungible::Mutate<AccountId>>::transfer(source, dest, amount, preservation),
Left(()) => {
<Left as fungible::Mutate<AccountId>>::transfer(source, dest, amount, preservation)
},
Right(a) => <Right as fungibles::Mutate<AccountId>>::transfer(
a,
source,
@@ -541,8 +553,9 @@ impl<
precision: Precision,
) -> Result<Self::Balance, DispatchError> {
match Criterion::convert(asset) {
Left(()) =>
<Left as fungible::MutateHold<AccountId>>::release(reason, who, amount, precision),
Left(()) => {
<Left as fungible::MutateHold<AccountId>>::release(reason, who, amount, precision)
},
Right(a) => <Right as fungibles::MutateHold<AccountId>>::release(
a, reason, who, amount, precision,
),
@@ -634,8 +647,9 @@ impl<
) -> DispatchResult {
match Criterion::convert(asset) {
Left(()) => <Left as fungible::MutateFreeze<AccountId>>::set_freeze(id, who, amount),
Right(a) =>
<Right as fungibles::MutateFreeze<AccountId>>::set_freeze(a, id, who, amount),
Right(a) => {
<Right as fungibles::MutateFreeze<AccountId>>::set_freeze(a, id, who, amount)
},
}
}
fn extend_freeze(
@@ -646,8 +660,9 @@ impl<
) -> DispatchResult {
match Criterion::convert(asset) {
Left(()) => <Left as fungible::MutateFreeze<AccountId>>::extend_freeze(id, who, amount),
Right(a) =>
<Right as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount),
Right(a) => {
<Right as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount)
},
}
}
fn thaw(asset: Self::AssetId, id: &Self::Id, who: &AccountId) -> DispatchResult {
@@ -723,9 +738,10 @@ impl<
match Criterion::convert(asset.clone()) {
Left(()) => <Left as fungible::Balanced<AccountId>>::deposit(who, value, precision)
.map(|d| fungibles::imbalance::from_fungible(d, asset)),
Right(a) =>
Right(a) => {
<Right as fungibles::Balanced<AccountId>>::deposit(a, who, value, precision)
.map(|d| fungibles::imbalance::from_fungibles(d, asset)),
.map(|d| fungibles::imbalance::from_fungibles(d, asset))
},
}
}
fn issue(asset: Self::AssetId, amount: Self::Balance) -> fungibles::Credit<AccountId, Self> {
@@ -959,8 +975,9 @@ impl<
fn touch(asset: AssetKind, who: &AccountId, depositor: &AccountId) -> DispatchResult {
match Criterion::convert(asset) {
Left(()) => <Left as AccountTouch<(), AccountId>>::touch((), who, depositor),
Right(a) =>
<Right as AccountTouch<Right::AssetId, AccountId>>::touch(a, who, depositor),
Right(a) => {
<Right as AccountTouch<Right::AssetId, AccountId>>::touch(a, who, depositor)
},
}
}
}
@@ -113,10 +113,12 @@ impl<
provenance: Provenance,
) -> DepositConsequence {
match Criterion::convert(asset) {
Left(a) =>
<Left as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance),
Right(a) =>
<Right as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance),
Left(a) => {
<Left as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance)
},
Right(a) => {
<Right as fungibles::Inspect<AccountId>>::can_deposit(a, who, amount, provenance)
},
}
}
fn can_withdraw(
@@ -153,21 +155,24 @@ impl<
force: Fortitude,
) -> Self::Balance {
match Criterion::convert(asset) {
Left(a) =>
Left(a) => {
<Left as fungibles::InspectHold<AccountId>>::reducible_total_balance_on_hold(
a, who, force,
),
Right(a) =>
)
},
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::reducible_total_balance_on_hold(
a, who, force,
),
)
},
}
}
fn hold_available(asset: Self::AssetId, reason: &Self::Reason, who: &AccountId) -> bool {
match Criterion::convert(asset) {
Left(a) => <Left as fungibles::InspectHold<AccountId>>::hold_available(a, reason, who),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::hold_available(a, reason, who),
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::hold_available(a, reason, who)
},
}
}
fn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance {
@@ -183,8 +188,9 @@ impl<
) -> Self::Balance {
match Criterion::convert(asset) {
Left(a) => <Left as fungibles::InspectHold<AccountId>>::balance_on_hold(a, reason, who),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::balance_on_hold(a, reason, who),
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::balance_on_hold(a, reason, who)
},
}
}
fn can_hold(
@@ -194,10 +200,12 @@ impl<
amount: Self::Balance,
) -> bool {
match Criterion::convert(asset) {
Left(a) =>
<Left as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount),
Right(a) =>
<Right as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount),
Left(a) => {
<Left as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount)
},
Right(a) => {
<Right as fungibles::InspectHold<AccountId>>::can_hold(a, reason, who, amount)
},
}
}
}
@@ -244,10 +252,12 @@ impl<
Self: Sized,
{
match Criterion::convert(dust.0) {
Left(a) =>
<Left as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1)),
Right(a) =>
<Right as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1)),
Left(a) => {
<Left as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1))
},
Right(a) => {
<Right as fungibles::Unbalanced<AccountId>>::handle_dust(fungibles::Dust(a, dust.1))
},
}
}
fn write_balance(
@@ -587,8 +597,9 @@ impl<
) -> DispatchResult {
match Criterion::convert(asset) {
Left(a) => <Left as fungibles::MutateFreeze<AccountId>>::set_freeze(a, id, who, amount),
Right(a) =>
<Right as fungibles::MutateFreeze<AccountId>>::set_freeze(a, id, who, amount),
Right(a) => {
<Right as fungibles::MutateFreeze<AccountId>>::set_freeze(a, id, who, amount)
},
}
}
fn extend_freeze(
@@ -598,10 +609,12 @@ impl<
amount: Self::Balance,
) -> DispatchResult {
match Criterion::convert(asset) {
Left(a) =>
<Left as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount),
Right(a) =>
<Right as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount),
Left(a) => {
<Left as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount)
},
Right(a) => {
<Right as fungibles::MutateFreeze<AccountId>>::extend_freeze(a, id, who, amount)
},
}
}
fn thaw(asset: Self::AssetId, id: &Self::Id, who: &AccountId) -> DispatchResult {
@@ -701,9 +714,10 @@ impl<
match Criterion::convert(asset.clone()) {
Left(a) => <Left as fungibles::Balanced<AccountId>>::deposit(a, who, value, precision)
.map(|debt| imbalance::from_fungibles(debt, asset)),
Right(a) =>
Right(a) => {
<Right as fungibles::Balanced<AccountId>>::deposit(a, who, value, precision)
.map(|debt| imbalance::from_fungibles(debt, asset)),
.map(|debt| imbalance::from_fungibles(debt, asset))
},
}
}
fn issue(asset: Self::AssetId, amount: Self::Balance) -> fungibles::Credit<AccountId, Self> {
@@ -895,8 +909,9 @@ impl<
min_balance: Self::Balance,
) -> DispatchResult {
match Criterion::convert(asset) {
Left(a) =>
<Left as fungibles::Create<AccountId>>::create(a, admin, is_sufficient, min_balance),
Left(a) => {
<Left as fungibles::Create<AccountId>>::create(a, admin, is_sufficient, min_balance)
},
Right(a) => <Right as fungibles::Create<AccountId>>::create(
a,
admin,
@@ -939,8 +954,9 @@ impl<
fn touch(asset: AssetKind, who: &AccountId, depositor: &AccountId) -> DispatchResult {
match Criterion::convert(asset) {
Left(a) => <Left as AccountTouch<Left::AssetId, AccountId>>::touch(a, who, depositor),
Right(a) =>
<Right as AccountTouch<Right::AssetId, AccountId>>::touch(a, who, depositor),
Right(a) => {
<Right as AccountTouch<Right::AssetId, AccountId>>::touch(a, who, depositor)
},
}
}
}
@@ -54,10 +54,12 @@ impl<
/// both.
pub fn merge(self, other: Self) -> Self {
match (self, other) {
(SignedImbalance::Positive(one), SignedImbalance::Positive(other)) =>
SignedImbalance::Positive(one.merge(other)),
(SignedImbalance::Negative(one), SignedImbalance::Negative(other)) =>
SignedImbalance::Negative(one.merge(other)),
(SignedImbalance::Positive(one), SignedImbalance::Positive(other)) => {
SignedImbalance::Positive(one.merge(other))
},
(SignedImbalance::Negative(one), SignedImbalance::Negative(other)) => {
SignedImbalance::Negative(one.merge(other))
},
(SignedImbalance::Positive(one), SignedImbalance::Negative(other)) => {
match one.offset(other) {
SameOrOther::Same(positive) => SignedImbalance::Positive(positive),
@@ -90,7 +90,7 @@ impl std::str::FromStr for Select {
match s {
"all" | "All" => Ok(Select::All),
"none" | "None" => Ok(Select::None),
_ =>
_ => {
if s.starts_with("rr-") {
let count = s
.split_once('-')
@@ -108,7 +108,8 @@ impl std::str::FromStr for Select {
} else {
let pallets = s.split(',').map(|x| x.as_bytes().to_vec()).collect::<Vec<_>>();
Ok(Select::Only(pallets))
},
}
},
}
}
}
@@ -365,8 +365,8 @@ fn valid_call_weight_test() {
dispatch_success: true,
call_weight: pallet1::CALL_2_WEIGHT,
ext_weight: pallet1::CALL_2_AUTH_WEIGHT,
actual_weight: pallet1::CALL_2_REFUND + pallet1::CALL_2_AUTH_WEIGHT -
call_2_auth_weight_refund,
actual_weight: pallet1::CALL_2_REFUND + pallet1::CALL_2_AUTH_WEIGHT
- call_2_auth_weight_refund,
},
Test {
call: RuntimeCall::Pallet1Instance2(pallet1::Call::call3 { valid: true, some_gen: 1 }),
@@ -1871,9 +1871,9 @@ fn metadata_v15() {
},
];
let empty_doc = pallets[0].event.as_ref().unwrap().ty.type_info().docs.is_empty() &&
pallets[0].error.as_ref().unwrap().ty.type_info().docs.is_empty() &&
pallets[0].calls.as_ref().unwrap().ty.type_info().docs.is_empty();
let empty_doc = pallets[0].event.as_ref().unwrap().ty.type_info().docs.is_empty()
&& pallets[0].error.as_ref().unwrap().ty.type_info().docs.is_empty()
&& pallets[0].calls.as_ref().unwrap().ty.type_info().docs.is_empty();
if cfg!(feature = "no-metadata-docs") {
assert!(empty_doc)
@@ -2462,8 +2462,8 @@ fn post_runtime_upgrade_detects_storage_version_issues() {
// The version isn't changed, we should detect it.
assert!(
Executive::try_runtime_upgrade(UpgradeCheckSelect::PreAndPost).unwrap_err() ==
"On chain and in-code storage version do not match. Missing runtime upgrade?"
Executive::try_runtime_upgrade(UpgradeCheckSelect::PreAndPost).unwrap_err()
== "On chain and in-code storage version do not match. Missing runtime upgrade?"
.into()
);
});
@@ -2493,8 +2493,8 @@ fn post_runtime_upgrade_detects_storage_version_issues() {
// any storage version "enabled".
assert!(
ExecutiveWithUpgradePallet4::try_runtime_upgrade(UpgradeCheckSelect::PreAndPost)
.unwrap_err() ==
"On chain storage version set, while the pezpallet \
.unwrap_err()
== "On chain storage version set, while the pezpallet \
doesn't have the `#[pezpallet::storage_version(VERSION)]` attribute."
.into()
);
@@ -2523,11 +2523,11 @@ fn test_dispatch_context() {
fn test_call_feature_parsing() {
let call = pezpallet::Call::<Runtime>::check_for_dispatch_context {};
match call {
pezpallet::Call::<Runtime>::check_for_dispatch_context {} |
pezpallet::Call::<Runtime>::foo { .. } |
pezpallet::Call::foo_storage_layer { .. } |
pezpallet::Call::foo_index_out_of_order {} |
pezpallet::Call::foo_no_post_info {} => (),
pezpallet::Call::<Runtime>::check_for_dispatch_context {}
| pezpallet::Call::<Runtime>::foo { .. }
| pezpallet::Call::foo_storage_layer { .. }
| pezpallet::Call::foo_index_out_of_order {}
| pezpallet::Call::foo_no_post_info {} => (),
#[cfg(feature = "frame-feature-testing")]
pezpallet::Call::foo_feature_test {} => (),
pezpallet::Call::__Ignore(_, _) => (),
@@ -2539,11 +2539,11 @@ fn test_call_feature_parsing() {
fn test_error_feature_parsing() {
let err = pezpallet::Error::<Runtime>::InsufficientProposersBalance;
match err {
pezpallet::Error::InsufficientProposersBalance |
pezpallet::Error::NonExistentStorageValue |
pezpallet::Error::Code(_) |
pezpallet::Error::Skipped(_) |
pezpallet::Error::CompactU8(_) => (),
pezpallet::Error::InsufficientProposersBalance
| pezpallet::Error::NonExistentStorageValue
| pezpallet::Error::Code(_)
| pezpallet::Error::Skipped(_)
| pezpallet::Error::CompactU8(_) => (),
#[cfg(feature = "frame-feature-testing")]
pezpallet::Error::FeatureTest => (),
pezpallet::Error::__Ignore(_, _) => (),
@@ -121,7 +121,8 @@ fn tasks_work() {
pezframe_support::assert_ok!(System::do_task(RuntimeOrigin::signed(1), task.clone(),));
assert_eq!(my_pezpallet::SomeStorage::<Runtime>::get(), (0, 2));
let task = RuntimeTask::MyPallet2(my_pezpallet::Task::<Runtime, _>::Foo { _i: 0u32, _j: 2u64 });
let task =
RuntimeTask::MyPallet2(my_pezpallet::Task::<Runtime, _>::Foo { _i: 0u32, _j: 2u64 });
pezframe_support::assert_ok!(System::do_task(RuntimeOrigin::signed(1), task.clone(),));
assert_eq!(my_pezpallet::SomeStorage::<Runtime, Instance2>::get(), (0, 2));