From 8e60711265c1db4e68f280b0331b885dabf5b57b Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 9 Jun 2025 09:31:55 +0100 Subject: [PATCH] Use the anonymous lifetime for paths New clippy lint in rustc nightly "lifetime flowing from input to output with different syntax can be confusing". Apply the suggested fix and use the anonymous lifetime for paths. --- bitcoin/src/bip32.rs | 6 +++--- bitcoin/src/blockdata/script/borrowed.rs | 8 ++++---- bitcoin/src/blockdata/transaction.rs | 2 +- bitcoin/src/taproot/mod.rs | 4 ++-- io/src/lib.rs | 2 +- primitives/src/witness.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index e6d9621b1..c1bff9170 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -416,17 +416,17 @@ impl DerivationPath { /// Get an [Iterator] over the children of this [DerivationPath] /// starting with the given [ChildNumber]. - pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator { + pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(self, cn) } /// Get an [Iterator] over the unhardened children of this [DerivationPath]. - pub fn normal_children(&self) -> DerivationPathIterator { + pub fn normal_children(&self) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(self, ChildNumber::Normal { index: 0 }) } /// Get an [Iterator] over the hardened children of this [DerivationPath]. - pub fn hardened_children(&self) -> DerivationPathIterator { + pub fn hardened_children(&self) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(self, ChildNumber::Hardened { index: 0 }) } diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index a6b36b198..6164c0a9c 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -331,7 +331,7 @@ crate::internal_macros::define_extension_trait! { /// /// To force minimal pushes, use [`instructions_minimal`](Self::instructions_minimal). #[inline] - fn instructions(&self) -> Instructions { + fn instructions(&self) -> Instructions<'_> { Instructions { data: self.as_bytes().iter(), enforce_minimal: false } } @@ -340,7 +340,7 @@ crate::internal_macros::define_extension_trait! { /// This is similar to [`instructions`](Self::instructions) but an error is returned if a push /// is not minimal. #[inline] - fn instructions_minimal(&self) -> Instructions { + fn instructions_minimal(&self) -> Instructions<'_> { Instructions { data: self.as_bytes().iter(), enforce_minimal: true } } @@ -352,7 +352,7 @@ crate::internal_macros::define_extension_trait! { /// /// To force minimal pushes, use [`Self::instruction_indices_minimal`]. #[inline] - fn instruction_indices(&self) -> InstructionIndices { + fn instruction_indices(&self) -> InstructionIndices<'_> { InstructionIndices::from_instructions(self.instructions()) } @@ -361,7 +361,7 @@ crate::internal_macros::define_extension_trait! { /// This is similar to [`instruction_indices`](Self::instruction_indices) but an error is /// returned if a push is not minimal. #[inline] - fn instruction_indices_minimal(&self) -> InstructionIndices { + fn instruction_indices_minimal(&self) -> InstructionIndices<'_> { InstructionIndices::from_instructions(self.instructions_minimal()) } diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 6182308f5..a07a82e99 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -404,7 +404,7 @@ impl TransactionExt for Transaction { fn is_lock_time_enabled(&self) -> bool { self.input.iter().any(|i| i.enables_lock_time()) } - fn script_pubkey_lens(&self) -> TxOutToScriptPubkeyLengthIter { + fn script_pubkey_lens(&self) -> TxOutToScriptPubkeyLengthIter<'_> { TxOutToScriptPubkeyLengthIter { inner: self.output.iter() } } diff --git a/bitcoin/src/taproot/mod.rs b/bitcoin/src/taproot/mod.rs index 723f61a87..f69434d21 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -779,7 +779,7 @@ impl TapTree { /// Returns [`TapTreeIter<'_>`] iterator for a Taproot script tree, operating in DFS order over /// tree [`ScriptLeaf`]s. - pub fn script_leaves(&self) -> ScriptLeaves { ScriptLeaves { leaf_iter: self.0.leaf_nodes() } } + pub fn script_leaves(&self) -> ScriptLeaves<'_> { ScriptLeaves { leaf_iter: self.0.leaf_nodes() } } /// Returns the root [`TapNodeHash`] of this tree. pub fn root_hash(&self) -> TapNodeHash { self.0.hash } @@ -951,7 +951,7 @@ impl NodeInfo { } /// Creates an iterator over all leaves (including hidden leaves) in the tree. - pub fn leaf_nodes(&self) -> LeafNodes { LeafNodes { leaf_iter: self.leaves.iter() } } + pub fn leaf_nodes(&self) -> LeafNodes<'_> { LeafNodes { leaf_iter: self.leaves.iter() } } /// Returns the root [`TapNodeHash`] of this node info. pub fn node_hash(&self) -> TapNodeHash { self.hash } diff --git a/io/src/lib.rs b/io/src/lib.rs index e5bf1e1eb..7e2bbb442 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -85,7 +85,7 @@ pub trait Read { /// Constructs a new adapter which will read at most `limit` bytes. #[inline] - fn take(&mut self, limit: u64) -> Take { Take { reader: self, remaining: limit } } + fn take(&mut self, limit: u64) -> Take<'_, Self> { Take { reader: self, remaining: limit } } /// Attempts to read up to limit bytes from the reader, allocating space in `buf` as needed. /// diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs index 78bb13d8d..02f9c7a78 100644 --- a/primitives/src/witness.rs +++ b/primitives/src/witness.rs @@ -111,7 +111,7 @@ impl Witness { /// Returns a struct implementing [`Iterator`]. #[must_use = "iterators are lazy and do nothing unless consumed"] #[inline] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { Iter { inner: self.content.as_slice(), indices_start: self.indices_start, current_index: 0 } }