Skip to content

Commit 03c6587

Browse files
committed
Remove unneeded explicit reference
Clippy emits a bunch of warnings of the form warning: this expression borrows a reference (`&Self`) that is immediately dereferenced by the compiler As suggested, remove the unneeded explicit reference.
1 parent 952af97 commit 03c6587

File tree

13 files changed

+43
-43
lines changed

13 files changed

+43
-43
lines changed

src/descriptor/bare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ where
111111
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
112112
{
113113
fn from_tree(top: &expression::Tree) -> Result<Self, Error> {
114-
let sub = Miniscript::<Pk, BareCtx>::from_tree(&top)?;
114+
let sub = Miniscript::<Pk, BareCtx>::from_tree(top)?;
115115
BareCtx::top_level_checks(&sub)?;
116116
Bare::new(sub)
117117
}

src/descriptor/key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ impl DescriptorXKey<bip32::ExtendedPrivKey> {
172172

173173
let xprv = self
174174
.xkey
175-
.derive_priv(&secp, &hardened_path)
175+
.derive_priv(secp, &hardened_path)
176176
.map_err(|_| DescriptorKeyParseError("Unable to derive the hardened steps"))?;
177-
let xpub = bip32::ExtendedPubKey::from_priv(&secp, &xprv);
177+
let xpub = bip32::ExtendedPubKey::from_priv(secp, &xprv);
178178

179179
let origin = match &self.origin {
180180
Some((fingerprint, path)) => Some((
@@ -188,7 +188,7 @@ impl DescriptorXKey<bip32::ExtendedPrivKey> {
188188
if hardened_path.is_empty() {
189189
None
190190
} else {
191-
Some((self.xkey.fingerprint(&secp), hardened_path.into()))
191+
Some((self.xkey.fingerprint(secp), hardened_path.into()))
192192
}
193193
}
194194
};

src/descriptor/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ impl Descriptor<DescriptorPublicKey> {
712712
key_map: &mut KeyMap|
713713
-> Result<DescriptorPublicKey, DescriptorKeyParseError> {
714714
let (public_key, secret_key) = match DescriptorSecretKey::from_str(s) {
715-
Ok(sk) => (sk.to_public(&secp)?, Some(sk)),
715+
Ok(sk) => (sk.to_public(secp)?, Some(sk)),
716716
Err(_) => (DescriptorPublicKey::from_str(s)?, None),
717717
};
718718

@@ -774,7 +774,7 @@ impl Descriptor<DescriptorPublicKey> {
774774
let range = if self.is_deriveable() { range } else { 0..1 };
775775

776776
for i in range {
777-
let concrete = self.derived_descriptor(&secp, i)?;
777+
let concrete = self.derived_descriptor(secp, i)?;
778778
if &concrete.script_pubkey() == script_pubkey {
779779
return Ok(Some((i, concrete)));
780780
}

src/descriptor/pretaproot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub(crate) mod traits {
259259
{
260260
// This expect can technically be avoided if we implement this for types, but
261261
// having this expect saves lots of LoC because of default implementation
262-
<Self as DescriptorTrait<Pk>>::explicit_script(&self)
262+
<Self as DescriptorTrait<Pk>>::explicit_script(self)
263263
.expect("Pre taproot descriptor have explicit script")
264264
}
265265

@@ -269,7 +269,7 @@ pub(crate) mod traits {
269269
where
270270
Pk: ToPublicKey,
271271
{
272-
<Self as DescriptorTrait<Pk>>::script_code(&self)
272+
<Self as DescriptorTrait<Pk>>::script_code(self)
273273
.expect("Pre taproot descriptor have non-failing script code")
274274
}
275275
}

src/descriptor/segwitv0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ where
140140
let top = &top.args[0];
141141
if top.name == "sortedmulti" {
142142
return Ok(Wsh {
143-
inner: WshInner::SortedMulti(SortedMultiVec::from_tree(&top)?),
143+
inner: WshInner::SortedMulti(SortedMultiVec::from_tree(top)?),
144144
});
145145
}
146-
let sub = Miniscript::from_tree(&top)?;
146+
let sub = Miniscript::from_tree(top)?;
147147
Segwitv0::top_level_checks(&sub)?;
148148
Ok(Wsh {
149149
inner: WshInner::Ms(sub),

src/descriptor/sh.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ where
103103
if top.name == "sh" && top.args.len() == 1 {
104104
let top = &top.args[0];
105105
let inner = match top.name {
106-
"wsh" => ShInner::Wsh(Wsh::from_tree(&top)?),
107-
"wpkh" => ShInner::Wpkh(Wpkh::from_tree(&top)?),
108-
"sortedmulti" => ShInner::SortedMulti(SortedMultiVec::from_tree(&top)?),
106+
"wsh" => ShInner::Wsh(Wsh::from_tree(top)?),
107+
"wpkh" => ShInner::Wpkh(Wpkh::from_tree(top)?),
108+
"sortedmulti" => ShInner::SortedMulti(SortedMultiVec::from_tree(top)?),
109109
_ => {
110-
let sub = Miniscript::from_tree(&top)?;
110+
let sub = Miniscript::from_tree(top)?;
111111
Legacy::top_level_checks(&sub)?;
112112
ShInner::Ms(sub)
113113
}

src/descriptor/tr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ where
322322
let (depth, last) = self.stack.pop().expect("Size checked above");
323323
match &*last {
324324
TapTree::Tree(l, r) => {
325-
self.stack.push((depth + 1, &r));
326-
self.stack.push((depth + 1, &l));
325+
self.stack.push((depth + 1, r));
326+
self.stack.push((depth + 1, l));
327327
}
328328
TapTree::Leaf(ref ms) => return Some((depth, ms)),
329329
}
@@ -533,7 +533,7 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for TapTree<Pk> {
533533
}
534534
}
535535

536-
let pol = lift_helper(&self)?;
536+
let pol = lift_helper(self)?;
537537
Ok(pol.normalized())
538538
}
539539
}
@@ -594,15 +594,15 @@ impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Tr<Pk> {
594594
Pk: ToPublicKey,
595595
S: Satisfier<Pk>,
596596
{
597-
best_tap_spend(&self, satisfier, false /* allow_mall */)
597+
best_tap_spend(self, satisfier, false /* allow_mall */)
598598
}
599599

600600
fn get_satisfaction_mall<S>(&self, satisfier: S) -> Result<(Vec<Vec<u8>>, Script), Error>
601601
where
602602
Pk: ToPublicKey,
603603
S: Satisfier<Pk>,
604604
{
605-
best_tap_spend(&self, satisfier, true /* allow_mall */)
605+
best_tap_spend(self, satisfier, true /* allow_mall */)
606606
}
607607

608608
fn max_satisfaction_weight(&self) -> Result<usize, Error> {

src/interpreter/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ impl<'txin> Interpreter<'txin> {
254254
let script_pubkey = self.script_code.as_ref().expect("Legacy have script code");
255255
let sighash = if self.is_legacy() {
256256
let sighash_u32 = ecdsa_sig.hash_ty.to_u32();
257-
cache.legacy_signature_hash(input_idx, &script_pubkey, sighash_u32)
257+
cache.legacy_signature_hash(input_idx, script_pubkey, sighash_u32)
258258
} else if self.is_segwit_v0() {
259259
let amt = match get_prevout(prevouts, input_idx) {
260260
Some(txout) => txout.borrow().value,
261261
None => return false,
262262
};
263-
cache.segwit_signature_hash(input_idx, &script_pubkey, amt, ecdsa_sig.hash_ty)
263+
cache.segwit_signature_hash(input_idx, script_pubkey, amt, ecdsa_sig.hash_ty)
264264
} else {
265265
// taproot(or future) signatures in segwitv0 context
266266
return false;
@@ -280,7 +280,7 @@ impl<'txin> Interpreter<'txin> {
280280
of script code for script spend",
281281
);
282282
let leaf_hash = taproot::TapLeafHash::from_script(
283-
&tap_script,
283+
tap_script,
284284
taproot::LeafVersion::TapScript,
285285
);
286286
cache.taproot_script_spend_signature_hash(
@@ -296,7 +296,7 @@ impl<'txin> Interpreter<'txin> {
296296
let msg =
297297
sighash_msg.map(|hash| secp256k1::Message::from_slice(&hash).expect("32 byte"));
298298
let success =
299-
msg.map(|msg| secp.verify_schnorr(&schnorr_sig.sig, &msg, &xpk).is_ok());
299+
msg.map(|msg| secp.verify_schnorr(&schnorr_sig.sig, &msg, xpk).is_ok());
300300
success.unwrap_or(false) // unwrap_or_default checks for errors, while success would have checksig results
301301
}
302302
}
@@ -975,7 +975,7 @@ where
975975
//Pk based descriptor
976976
if let Some(pk) = self.public_key {
977977
if let Some(stack::Element::Push(sig)) = self.stack.pop() {
978-
if let Ok(key_sig) = verify_sersig(&mut self.verify_sig, &pk, &sig) {
978+
if let Ok(key_sig) = verify_sersig(&mut self.verify_sig, pk, sig) {
979979
//Signature check successful, set public_key to None to
980980
//terminate the next() function in the subsequent call
981981
self.public_key = None;

src/miniscript/analyzable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
8383
// It maybe possible to return a detail error type containing why the miniscript
8484
// failed. But doing so may require returning a collection of errors
8585
pub fn within_resource_limits(&self) -> bool {
86-
match Ctx::check_local_validity(&self) {
86+
match Ctx::check_local_validity(self) {
8787
Ok(_) => true,
8888
Err(_) => false,
8989
}

src/miniscript/astelem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
659659
Terminal::PkH(ref hash) => builder
660660
.push_opcode(opcodes::all::OP_DUP)
661661
.push_opcode(opcodes::all::OP_HASH160)
662-
.push_slice(&Pk::hash_to_hash160(&hash)[..])
662+
.push_slice(&Pk::hash_to_hash160(hash)[..])
663663
.push_opcode(opcodes::all::OP_EQUALVERIFY),
664664
Terminal::After(t) => builder
665665
.push_int(t as i64)

0 commit comments

Comments
 (0)