Skip to content

Commit bf44938

Browse files
committed
Remove unneeded calls to clone
Clippy emits two warnings related to unneeded calls to clone.
1 parent 227a3a9 commit bf44938

File tree

6 files changed

+16
-28
lines changed

6 files changed

+16
-28
lines changed

src/descriptor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ mod tests {
12321232
sequence: Sequence::from_height(100),
12331233
witness: Witness::default(),
12341234
};
1235-
let bare = Descriptor::new_bare(ms.clone()).unwrap();
1235+
let bare = Descriptor::new_bare(ms).unwrap();
12361236

12371237
bare.satisfy(&mut txin, &satisfier).expect("satisfaction");
12381238
assert_eq!(

src/descriptor/sortedmulti.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ mod tests {
258258

259259
let mut pks = Vec::new();
260260
for _ in 0..over {
261-
pks.push(pk.clone());
261+
pks.push(pk);
262262
}
263263

264264
let res: Result<SortedMultiVec<PublicKey, Legacy>, Error> = SortedMultiVec::new(0, pks);

src/interpreter/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ mod tests {
820820
from_txdata(&spk, &script_sig, &empty_wit).expect("parse txdata");
821821
assert_eq!(inner, Inner::Script(miniscript, ScriptType::Sh));
822822
assert_eq!(stack, Stack::from(vec![]));
823-
assert_eq!(script_code, Some(redeem_script.clone()));
823+
assert_eq!(script_code, Some(redeem_script));
824824

825825
// nonempty witness
826826
let wit = Witness::from_vec(vec![vec![]]);

src/miniscript/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub mod test {
275275
let preimage = vec![0xab as u8; 32];
276276
let sha256_hash = sha256::Hash::hash(&preimage);
277277
let sha256d_hash_rev = sha256d::Hash::hash(&preimage);
278-
let mut sha256d_hash_bytes = sha256d_hash_rev.clone().into_inner();
278+
let mut sha256d_hash_bytes = sha256d_hash_rev.into_inner();
279279
sha256d_hash_bytes.reverse();
280280
let sha256d_hash = sha256d::Hash::from_inner(sha256d_hash_bytes);
281281
let hash160_hash = hash160::Hash::hash(&preimage);

src/policy/semantic.rs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,8 @@ mod tests {
694694
assert_eq!(policy, Policy::Key("".to_owned()));
695695
assert_eq!(policy.relative_timelocks(), vec![]);
696696
assert_eq!(policy.absolute_timelocks(), vec![]);
697-
assert_eq!(policy.clone().at_age(Sequence::ZERO), policy.clone());
698-
assert_eq!(
699-
policy.clone().at_age(Sequence::from_height(10000)),
700-
policy.clone()
701-
);
697+
assert_eq!(policy.clone().at_age(Sequence::ZERO), policy);
698+
assert_eq!(policy.clone().at_age(Sequence::from_height(10000)), policy);
702699
assert_eq!(policy.n_keys(), 1);
703700
assert_eq!(policy.minimum_n_keys(), Some(1));
704701

@@ -711,14 +708,8 @@ mod tests {
711708
policy.clone().at_age(Sequence::from_height(999)),
712709
Policy::Unsatisfiable
713710
);
714-
assert_eq!(
715-
policy.clone().at_age(Sequence::from_height(1000)),
716-
policy.clone()
717-
);
718-
assert_eq!(
719-
policy.clone().at_age(Sequence::from_height(10000)),
720-
policy.clone()
721-
);
711+
assert_eq!(policy.clone().at_age(Sequence::from_height(1000)), policy);
712+
assert_eq!(policy.clone().at_age(Sequence::from_height(10000)), policy);
722713
assert_eq!(policy.n_keys(), 0);
723714
assert_eq!(policy.minimum_n_keys(), Some(0));
724715

@@ -843,13 +834,13 @@ mod tests {
843834
policy
844835
.clone()
845836
.at_lock_time(LockTime::from_height(1000).expect("valid block height")),
846-
policy.clone()
837+
policy
847838
);
848839
assert_eq!(
849840
policy
850841
.clone()
851842
.at_lock_time(LockTime::from_height(10000).expect("valid block height")),
852-
policy.clone()
843+
policy
853844
);
854845
// Pass a UNIX timestamp to at_lock_time while policy uses a block height.
855846
assert_eq!(
@@ -906,13 +897,13 @@ mod tests {
906897
policy
907898
.clone()
908899
.at_lock_time(LockTime::from_time(500_000_010).expect("valid timestamp")),
909-
policy.clone()
900+
policy
910901
);
911902
assert_eq!(
912903
policy
913904
.clone()
914905
.at_lock_time(LockTime::from_time(500_000_012).expect("valid timestamp")),
915-
policy.clone()
906+
policy
916907
);
917908
assert_eq!(policy.n_keys(), 0);
918909
assert_eq!(policy.minimum_n_keys(), Some(0));
@@ -933,7 +924,6 @@ mod tests {
933924
// test liquid backup policy before the emergency timeout
934925
let backup_policy = StringPolicy::from_str("thresh(2,pk(A),pk(B),pk(C))").unwrap();
935926
assert!(!backup_policy
936-
.clone()
937927
.entails(liquid_pol.clone().at_age(Sequence::from_height(4095)))
938928
.unwrap());
939929

@@ -942,9 +932,7 @@ mod tests {
942932
let backup_policy_after_expiry =
943933
StringPolicy::from_str("and(older(4096),thresh(2,pk(A),pk(B),pk(C)))").unwrap();
944934
assert!(fed_pol.entails(liquid_pol.clone()).unwrap());
945-
assert!(backup_policy_after_expiry
946-
.entails(liquid_pol.clone())
947-
.unwrap());
935+
assert!(backup_policy_after_expiry.entails(liquid_pol).unwrap());
948936
}
949937

950938
#[test]

src/psbt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ mod tests {
16961696
output: vec![],
16971697
};
16981698

1699-
let mut psbt = Psbt::from_unsigned_tx(tx.clone()).unwrap();
1699+
let mut psbt = Psbt::from_unsigned_tx(tx).unwrap();
17001700
assert_eq!(
17011701
psbt.update_input_with_descriptor(0, &desc),
17021702
Err(UtxoUpdateError::UtxoCheck),
@@ -1715,7 +1715,7 @@ mod tests {
17151715
"matching non_witness_utxo"
17161716
);
17171717
non_witness_utxo.version = 0;
1718-
psbt.inputs[0].non_witness_utxo = Some(non_witness_utxo.clone());
1718+
psbt.inputs[0].non_witness_utxo = Some(non_witness_utxo);
17191719
assert_eq!(
17201720
psbt.update_input_with_descriptor(0, &desc),
17211721
Err(UtxoUpdateError::UtxoCheck),
@@ -1748,7 +1748,7 @@ mod tests {
17481748
}],
17491749
};
17501750

1751-
let mut psbt = Psbt::from_unsigned_tx(tx.clone()).unwrap();
1751+
let mut psbt = Psbt::from_unsigned_tx(tx).unwrap();
17521752
assert_eq!(
17531753
psbt.update_output_with_descriptor(1, &desc),
17541754
Err(OutputUpdateError::IndexOutOfBounds(1, 1)),

0 commit comments

Comments
 (0)