From 8e60711265c1db4e68f280b0331b885dabf5b57b Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 9 Jun 2025 09:31:55 +0100 Subject: [PATCH 1/3] 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 } } From 69ce8f448b7f786f16449a261e09e75c918f7dbb Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 9 Jun 2025 09:35:44 +0100 Subject: [PATCH 2/3] Remove unneeded return statement New clipply lint in rustc nightly "unneeded `return` statement". Remove it. --- bitcoin/src/blockdata/transaction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index a07a82e99..f169f4168 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -517,11 +517,11 @@ impl TransactionExtPriv for Transaction { 1 } else if witness_program.is_p2wsh() { // Treat the last item of the witness as the witnessScript - return witness + witness .last() .map(Script::from_bytes) .map(|s| s.count_sigops()) - .unwrap_or(0); + .unwrap_or(0) } else { 0 } From 47c07c39fb2af99c348124d45a3cb8f92deb60dd Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 9 Jun 2025 09:38:36 +0100 Subject: [PATCH 3/3] Manual update to rustc (to nightly-2025-06-06) Automated daily update failed due to the new lints. Update the nightly version now lints are fixed. --- nightly-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nightly-version b/nightly-version index 0ed7b6b40..e1c42351e 100644 --- a/nightly-version +++ b/nightly-version @@ -1 +1 @@ -nightly-2025-05-23 +nightly-2025-06-06