Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 20b5aac

Browse files
authored
declone and close the door (#12035)
* declone and close the door * cargo fmt * remove brackets
1 parent 90c8ac3 commit 20b5aac

File tree

72 files changed

+344
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+344
-512
lines changed

.cargo/config.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ rustflags = [
1212
"-Aclippy::if-same-then-else",
1313
"-Aclippy::clone-double-ref",
1414
"-Dclippy::complexity",
15-
"-Aclippy::clone_on_copy", # Too common
16-
"-Aclippy::needless_lifetimes", # Backward compat?
1715
"-Aclippy::zero-prefixed-literal", # 00_1000_000
1816
"-Aclippy::type_complexity", # raison d'etre
1917
"-Aclippy::nonminimal-bool", # maybe

bin/node/executor/tests/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
127127
let block2 = construct_block(
128128
&mut t,
129129
2,
130-
block1.1.clone(),
130+
block1.1,
131131
vec![
132132
CheckedExtrinsic {
133133
signed: None,

bin/node/executor/tests/fees.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
7373
let block2 = construct_block(
7474
&mut tt,
7575
2,
76-
block1.1.clone(),
76+
block1.1,
7777
vec![
7878
CheckedExtrinsic {
7979
signed: None,

bin/node/runtime/src/impls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ mod multiplier_tests {
197197
fn truth_value_update_poc_works() {
198198
let fm = Multiplier::saturating_from_rational(1, 2);
199199
let test_set = vec![
200-
(0, fm.clone()),
201-
(100, fm.clone()),
202-
(1000, fm.clone()),
203-
(target(), fm.clone()),
204-
(max_normal() / 2, fm.clone()),
205-
(max_normal(), fm.clone()),
200+
(0, fm),
201+
(100, fm),
202+
(1000, fm),
203+
(target(), fm),
204+
(max_normal() / 2, fm),
205+
(max_normal(), fm),
206206
];
207207
test_set.into_iter().for_each(|(w, fm)| {
208208
run_with_system_weight(w, || {

client/api/src/in_mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<Block: BlockT> Blockchain<Block> {
173173

174174
{
175175
let mut storage = self.storage.write();
176-
storage.leaves.import(hash, number, header.parent_hash().clone());
176+
storage.leaves.import(hash, number, *header.parent_hash());
177177
storage.blocks.insert(hash, StoredBlock::new(header, body, justifications));
178178

179179
if let NewBlockState::Final = new_state {

client/authority-discovery/src/worker/tests.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) struct TestApi {
4848
impl ProvideRuntimeApi<Block> for TestApi {
4949
type Api = RuntimeApi;
5050

51-
fn runtime_api<'a>(&'a self) -> ApiRef<'a, Self::Api> {
51+
fn runtime_api(&self) -> ApiRef<'_, Self::Api> {
5252
RuntimeApi { authorities: self.authorities.clone() }.into()
5353
}
5454
}
@@ -530,7 +530,7 @@ impl DhtValueFoundTester {
530530
) -> Option<&HashSet<Multiaddr>> {
531531
let (_dht_event_tx, dht_event_rx) = channel(1);
532532
let local_test_api =
533-
Arc::new(TestApi { authorities: vec![self.remote_authority_public.clone().into()] });
533+
Arc::new(TestApi { authorities: vec![self.remote_authority_public.into()] });
534534
let local_network: Arc<TestNetwork> = Arc::new(Default::default());
535535
let local_key_store = KeyStore::new();
536536

@@ -555,8 +555,7 @@ impl DhtValueFoundTester {
555555
self.local_worker
556556
.as_ref()
557557
.map(|w| {
558-
w.addr_cache
559-
.get_addresses_by_authority_id(&self.remote_authority_public.clone().into())
558+
w.addr_cache.get_addresses_by_authority_id(&self.remote_authority_public.into())
560559
})
561560
.unwrap()
562561
}
@@ -569,7 +568,7 @@ fn limit_number_of_addresses_added_to_cache_per_authority() {
569568
let addresses = (1..100).map(|i| tester.multiaddr_with_peer_id(i)).collect();
570569
let kv_pairs = block_on(build_dht_event::<TestNetwork>(
571570
addresses,
572-
tester.remote_authority_public.clone().into(),
571+
tester.remote_authority_public.into(),
573572
&tester.remote_key_store,
574573
None,
575574
));
@@ -584,7 +583,7 @@ fn strict_accept_address_with_peer_signature() {
584583
let addr = tester.multiaddr_with_peer_id(1);
585584
let kv_pairs = block_on(build_dht_event(
586585
vec![addr.clone()],
587-
tester.remote_authority_public.clone().into(),
586+
tester.remote_authority_public.into(),
588587
&tester.remote_key_store,
589588
Some(&TestSigner { keypair: &tester.remote_node_key }),
590589
));
@@ -604,7 +603,7 @@ fn reject_address_with_rogue_peer_signature() {
604603
let rogue_remote_node_key = Keypair::generate_ed25519();
605604
let kv_pairs = block_on(build_dht_event(
606605
vec![tester.multiaddr_with_peer_id(1)],
607-
tester.remote_authority_public.clone().into(),
606+
tester.remote_authority_public.into(),
608607
&tester.remote_key_store,
609608
Some(&TestSigner { keypair: &rogue_remote_node_key }),
610609
));
@@ -622,7 +621,7 @@ fn reject_address_with_invalid_peer_signature() {
622621
let mut tester = DhtValueFoundTester::new();
623622
let mut kv_pairs = block_on(build_dht_event(
624623
vec![tester.multiaddr_with_peer_id(1)],
625-
tester.remote_authority_public.clone().into(),
624+
tester.remote_authority_public.into(),
626625
&tester.remote_key_store,
627626
Some(&TestSigner { keypair: &tester.remote_node_key }),
628627
));
@@ -644,7 +643,7 @@ fn reject_address_without_peer_signature() {
644643
let mut tester = DhtValueFoundTester::new();
645644
let kv_pairs = block_on(build_dht_event::<TestNetwork>(
646645
vec![tester.multiaddr_with_peer_id(1)],
647-
tester.remote_authority_public.clone().into(),
646+
tester.remote_authority_public.into(),
648647
&tester.remote_key_store,
649648
None,
650649
));
@@ -662,7 +661,7 @@ fn do_not_cache_addresses_without_peer_id() {
662661
"/ip6/2001:db8:0:0:0:0:0:2/tcp/30333".parse().unwrap();
663662
let kv_pairs = block_on(build_dht_event::<TestNetwork>(
664663
vec![multiaddr_with_peer_id.clone(), multiaddr_without_peer_id],
665-
tester.remote_authority_public.clone().into(),
664+
tester.remote_authority_public.into(),
666665
&tester.remote_key_store,
667666
None,
668667
));

client/beefy/src/round.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ where
109109
}
110110

111111
pub(crate) fn should_self_vote(&self, round: &(P, NumberFor<B>)) -> bool {
112-
Some(round.1.clone()) > self.best_done &&
112+
Some(round.1) > self.best_done &&
113113
self.rounds.get(round).map(|tracker| !tracker.has_self_vote()).unwrap_or(true)
114114
}
115115

client/beefy/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn add_auth_change_digest(header: &mut Header, new_auth_set: BeefyValidatorSet)
326326
}
327327

328328
pub(crate) fn make_beefy_ids(keys: &[BeefyKeyring]) -> Vec<AuthorityId> {
329-
keys.iter().map(|key| key.clone().public().into()).collect()
329+
keys.iter().map(|&key| key.public().into()).collect()
330330
}
331331

332332
pub(crate) fn create_beefy_keystore(authority: BeefyKeyring) -> SyncCryptoStorePtr {

client/beefy/src/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ pub(crate) mod tests {
11341134
let mmr_root_hash = H256::random();
11351135
header.digest_mut().push(DigestItem::Consensus(
11361136
BEEFY_ENGINE_ID,
1137-
ConsensusLog::<AuthorityId>::MmrRoot(mmr_root_hash.clone()).encode(),
1137+
ConsensusLog::<AuthorityId>::MmrRoot(mmr_root_hash).encode(),
11381138
));
11391139

11401140
// verify validator set is correctly extracted from digest

client/cli/src/commands/chain_info_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ChainInfoCmd {
7777
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
7878
state_pruning: config.state_pruning.clone(),
7979
source: config.database.clone(),
80-
blocks_pruning: config.blocks_pruning.clone(),
80+
blocks_pruning: config.blocks_pruning,
8181
};
8282
let backend = sc_service::new_db_backend::<B>(db_config)?;
8383
let info: ChainInfo<B> = backend.blockchain().info().into();

0 commit comments

Comments
 (0)