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
+1 -1
View File
@@ -22,7 +22,7 @@ use std::{
sync::Arc,
};
const LOG_TARGET: &'static str = "level-monitor";
const LOG_TARGET: &str = "level-monitor";
/// Value good enough to be used with parachains using the current backend implementation
/// that ships with Substrate. This value may change in the future.
@@ -325,7 +325,6 @@ async fn handle_new_block_imported<Block, P>(
match parachain.block_status(unset_hash) {
Ok(BlockStatus::InChainWithState) => {
drop(unset_best_header);
let unset_best_header = unset_best_header_opt
.take()
.expect("We checked above that the value is set; qed");
@@ -433,8 +432,11 @@ async fn handle_new_best_parachain_head<Block, P>(
}
}
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
where
async fn import_block_as_new_best<Block, P>(
hash: Block::Hash,
header: Block::Header,
mut parachain: &P,
) where
Block: BlockT,
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
for<'a> &'a P: BlockImport<Block>,
@@ -456,7 +458,7 @@ where
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
block_import_params.import_existing = true;
if let Err(err) = (&*parachain).import_block(block_import_params).await {
if let Err(err) = parachain.import_block(block_import_params).await {
tracing::warn!(
target: LOG_TARGET,
block_hash = ?hash,
+2 -8
View File
@@ -337,7 +337,7 @@ fn follow_new_best_with_dummy_recovery_works() {
Some(recovery_chan_tx),
);
let block = build_block(&*client.clone(), None, None);
let block = build_block(&*client, None, None);
let block_clone = block.clone();
let client_clone = client.clone();
@@ -547,7 +547,6 @@ fn do_not_set_best_block_to_older_block() {
let client = Arc::new(TestClientBuilder::with_backend(backend).build());
let blocks = (0..NUM_BLOCKS)
.into_iter()
.map(|_| build_and_import_block(client.clone(), true))
.collect::<Vec<_>>();
@@ -559,7 +558,6 @@ fn do_not_set_best_block_to_older_block() {
let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}), None);
let client2 = client.clone();
let work = async move {
new_best_heads_sender
.unbounded_send(blocks[NUM_BLOCKS - 2].header().clone())
@@ -579,7 +577,7 @@ fn do_not_set_best_block_to_older_block() {
});
// Build and import a new best block.
build_and_import_block(client2.clone(), true);
build_and_import_block(client, true);
}
#[test]
@@ -607,7 +605,6 @@ fn prune_blocks_on_level_overflow() {
let id0 = block0.header.hash();
let blocks1 = (0..LEVEL_LIMIT)
.into_iter()
.map(|i| {
build_and_import_block_ext(
&*client,
@@ -622,7 +619,6 @@ fn prune_blocks_on_level_overflow() {
let id10 = blocks1[0].header.hash();
let blocks2 = (0..2)
.into_iter()
.map(|i| {
build_and_import_block_ext(
&*client,
@@ -720,7 +716,6 @@ fn restore_limit_monitor() {
let id00 = block00.header.hash();
let blocks1 = (0..LEVEL_LIMIT + 1)
.into_iter()
.map(|i| {
build_and_import_block_ext(
&*client,
@@ -735,7 +730,6 @@ fn restore_limit_monitor() {
let id10 = blocks1[0].header.hash();
let _ = (0..LEVEL_LIMIT)
.into_iter()
.map(|i| {
build_and_import_block_ext(
&*client,