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
+11 -15
View File
@@ -766,19 +766,19 @@ mod tests {
new_test_ext().execute_with(|| {
let enqueued = vec![msg(1000), msg(1001)];
enqueue(&enqueued);
let weight_used = handle_messages(&vec![msg(1002)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 0);
let weight_used = handle_messages(&vec![msg(1003)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1001, 1001));
assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]);
assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 1);
let weight_used = handle_messages(&vec![msg(1004)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1002, 1002));
assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]);
assert_eq!(pages_queued(), 2);
@@ -877,9 +877,9 @@ mod tests {
#[test]
fn on_idle_should_service_queue() {
new_test_ext().execute_with(|| {
enqueue(&vec![msg(1000), msg(1001)]);
enqueue(&vec![msg(1002), msg(1003)]);
enqueue(&vec![msg(1004), msg(1005)]);
enqueue(&[msg(1000), msg(1001)]);
enqueue(&[msg(1002), msg(1003)]);
enqueue(&[msg(1004), msg(1005)]);
let weight_used = DmpQueue::on_idle(1, Weight::from_parts(6000, 6000));
assert_eq!(weight_used, Weight::from_parts(5010, 5010));
@@ -901,20 +901,17 @@ mod tests {
#[test]
fn handle_max_messages_per_block() {
new_test_ext().execute_with(|| {
enqueue(&vec![msg(1000), msg(1001)]);
enqueue(&vec![msg(1002), msg(1003)]);
enqueue(&vec![msg(1004), msg(1005)]);
enqueue(&[msg(1000), msg(1001)]);
enqueue(&[msg(1002), msg(1003)]);
enqueue(&[msg(1004), msg(1005)]);
let incoming = (0..MAX_MESSAGES_PER_BLOCK)
.into_iter()
.map(|i| msg(1006 + i as u64))
.collect::<Vec<_>>();
let incoming =
(0..MAX_MESSAGES_PER_BLOCK).map(|i| msg(1006 + i as u64)).collect::<Vec<_>>();
handle_messages(&incoming, Weight::from_parts(25000, 25000));
assert_eq!(
take_trace(),
(0..MAX_MESSAGES_PER_BLOCK)
.into_iter()
.map(|i| msg_complete(1000 + i as u64))
.collect::<Vec<_>>(),
);
@@ -924,7 +921,6 @@ mod tests {
assert_eq!(
take_trace(),
(MAX_MESSAGES_PER_BLOCK..MAX_MESSAGES_PER_BLOCK + 6)
.into_iter()
.map(|i| msg_complete(1000 + i as u64))
.collect::<Vec<_>>(),
);
+1 -1
View File
@@ -74,7 +74,7 @@ pub fn migrate_to_v1<T: Config>() -> Weight {
}
};
if let Err(_) = Configuration::<T>::translate(|pre| pre.map(translate)) {
if Configuration::<T>::translate(|pre| pre.map(translate)).is_err() {
log::error!(
target: "dmp_queue",
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"