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
@@ -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))
},
}
},
}
}
}