Fix Clippy (#2522)

* Import Clippy config from Polkadot

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Auto clippy fix

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* No tabs in comments

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Prefer matches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Dont drop references

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Trivial

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Refactor

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add clippy to ci

* Clippy reborrow

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Partially revert 'Prefer matches'

Using matches! instead of match does give less compiler
checks as per review from @chevdor.

Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update .cargo/config.toml

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* Revert revert 💩

Should be fine to use matches! macro since it is an explicit whitelist,
not wildcard matching.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: alvicsam <alvicsam@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-05-06 08:01:03 +02:00
committed by GitHub
parent 4dc50c8d89
commit c312f0b9a6
92 changed files with 910 additions and 967 deletions
+9 -13
View File
@@ -163,7 +163,7 @@ impl<
// Get the local asset id in which we can pay for fees
let (local_asset_id, _) =
Matcher::matches_fungibles(&first).map_err(|_| XcmError::AssetNotFound)?;
Matcher::matches_fungibles(first).map_err(|_| XcmError::AssetNotFound)?;
// Calculate how much we should charge in the asset_id for such amount of weight
// Require at least a payment of minimum_balance
@@ -181,7 +181,7 @@ impl<
.map_err(|_| XcmError::Overflow)?;
// Convert to the same kind of multiasset, with the required fungible balance
let required = first.id.clone().into_multiasset(asset_balance.into());
let required = first.id.into_multiasset(asset_balance.into());
// Substract payment
let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?;
@@ -204,7 +204,7 @@ impl<
{
// Get the local asset id in which we can refund fees
let (local_asset_id, outstanding_balance) =
Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?;
Matcher::matches_fungibles(&(id, fun).into()).ok()?;
let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id);
@@ -233,8 +233,7 @@ impl<
let asset_balance: u128 = asset_balance.saturated_into();
// Construct outstanding_concrete_asset with the same location id and substracted balance
let outstanding_concrete_asset: MultiAsset =
(id.clone(), outstanding_minus_substracted).into();
let outstanding_concrete_asset: MultiAsset = (id, outstanding_minus_substracted).into();
// Substract from existing weight and balance
weight_outstanding = weight_outstanding.saturating_sub(weight);
@@ -365,7 +364,7 @@ mod tests {
// ParentAsUmp - check dest is really not applicable
let dest = (Parent, Parent, Parent);
let mut dest_wrapper = Some(dest.clone().into());
let mut dest_wrapper = Some(dest.into());
let mut msg_wrapper = Some(message.clone());
assert_eq!(
Err(SendError::NotApplicable),
@@ -373,7 +372,7 @@ mod tests {
);
// check wrapper were not consumed
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
assert_eq!(Some(dest.into()), dest_wrapper.take());
assert_eq!(Some(message.clone()), msg_wrapper.take());
// another try with router chain with asserting sender
@@ -393,7 +392,7 @@ mod tests {
// ParentAsUmp - check dest/msg is valid
let dest = (Parent, Here);
let mut dest_wrapper = Some(dest.clone().into());
let mut dest_wrapper = Some(dest.into());
let mut msg_wrapper = Some(message.clone());
assert!(<ParentAsUmp<(), (), ()> as SendXcm>::validate(
&mut dest_wrapper,
@@ -529,16 +528,13 @@ mod tests {
// prepare test data
let asset: MultiAsset = (Here, AMOUNT).into();
let payment = Assets::from(asset.clone());
let payment = Assets::from(asset);
let weight_to_buy = Weight::from_parts(1_000, 1_000);
// lets do first call (success)
assert_ok!(trader.buy_weight(weight_to_buy, payment.clone()));
// lets do second call (error)
assert_eq!(
trader.buy_weight(weight_to_buy, payment.clone()),
Err(XcmError::NotWithdrawable)
);
assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable));
}
}