Skip to content

Commit 6993c6f

Browse files
committed
Merge rust-bitcoin#5282: Fix all the lint warnings on 0.32.x branch
a2fe08c Use explicit link for feature gated rustdoc (Jamil Lambert, PhD) 4eb5f0a Fix stale rustdoc (Jamil Lambert, PhD) d6c29d0 Run the formatter on nightly (Jamil Lambert, PhD) fc91680 Clippy allow large error (Jamil Lambert, PhD) d8724cf Use canonical PartialOrd impl (Jamil Lambert, PhD) 2bee284 Remove manual implementation of ok (Jamil Lambert, PhD) f4993ec Fix rustdoc indenting (Jamil Lambert, PhD) f50deb7 Remove unneeded returns (Jamil Lambert, PhD) 2d9df5d Fix rustdoc syntax (Jamil Lambert, PhD) ae7733b Suppress lint warning about MSRV (Jamil Lambert, PhD) 2f59eb6 Elide lifetime to fix lint error (Jamil Lambert, PhD) dc9c9d1 Fix hiden lifetime lint (Jamil Lambert, PhD) Pull request description: See rust-bitcoin#5281 for reason. Use the current version of nightly on master (2025-09-26) to lint and format the v0.32.x branch. Fix all of the lint errors. Run the formatter. Fix some rustdoc issues. Closes rust-bitcoin#5281 ACKs for top commit: apoelstra: utACK a2fe08c ran my local CI on the tip Tree-SHA512: 51152a07d5d7a5c55af69fc37584a93218b316837625438589d13c4883bd76656b42895d703ece46834f7a48bb9375dc378be5ad44e72914d468aa33a08c29f9
2 parents ecffa6b + a2fe08c commit 6993c6f

File tree

33 files changed

+134
-155
lines changed

33 files changed

+134
-155
lines changed

base58/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ impl<T: Default + Copy> SmallVec<T> {
204204
}
205205
}
206206

207-
fn iter(&self) -> iter::Chain<slice::Iter<T>, slice::Iter<T>> {
207+
fn iter(&self) -> iter::Chain<slice::Iter<'_, T>, slice::Iter<'_, T>> {
208208
// If len<100 then we just append an empty vec
209209
self.stack[0..self.len].iter().chain(self.heap.iter())
210210
}
211211

212-
fn iter_mut(&mut self) -> iter::Chain<slice::IterMut<T>, slice::IterMut<T>> {
212+
fn iter_mut(&mut self) -> iter::Chain<slice::IterMut<'_, T>, slice::IterMut<'_, T>> {
213213
// If len<100 then we just append an empty vec
214214
self.stack[0..self.len].iter_mut().chain(self.heap.iter_mut())
215215
}

bitcoin/src/address/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub enum AddressType {
7575
/// Pay to taproot.
7676
P2tr,
7777
/// Pay to anchor.
78-
P2a
78+
P2a,
7979
}
8080

8181
impl fmt::Display for AddressType {
@@ -249,17 +249,17 @@ pub enum AddressData {
249249
/// Data encoded by a P2PKH address.
250250
P2pkh {
251251
/// The pubkey hash used to encumber outputs to this address.
252-
pubkey_hash: PubkeyHash
252+
pubkey_hash: PubkeyHash,
253253
},
254254
/// Data encoded by a P2SH address.
255255
P2sh {
256256
/// The script hash used to encumber outputs to this address.
257-
script_hash: ScriptHash
257+
script_hash: ScriptHash,
258258
},
259259
/// Data encoded by a Segwit address.
260260
Segwit {
261261
/// The witness program used to encumber outputs to this address.
262-
witness_program: WitnessProgram
262+
witness_program: WitnessProgram,
263263
},
264264
}
265265

@@ -565,7 +565,10 @@ impl Address {
565565
pub fn is_spend_standard(&self) -> bool { self.address_type().is_some() }
566566

567567
/// Constructs an [`Address`] from an output script (`scriptPubkey`).
568-
pub fn from_script(script: &Script, params: impl AsRef<Params>) -> Result<Address, FromScriptError> {
568+
pub fn from_script(
569+
script: &Script,
570+
params: impl AsRef<Params>,
571+
) -> Result<Address, FromScriptError> {
569572
let network = params.as_ref().network;
570573
if script.is_p2pkh() {
571574
let bytes = script.as_bytes()[3..23].try_into().expect("statically 20B long");

bitcoin/src/bip32.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl IntoDerivationPath for String {
298298
fn into_derivation_path(self) -> Result<DerivationPath, Error> { self.parse() }
299299
}
300300

301-
impl<'a> IntoDerivationPath for &'a str {
301+
impl IntoDerivationPath for &str {
302302
fn into_derivation_path(self) -> Result<DerivationPath, Error> { self.parse() }
303303
}
304304

@@ -405,17 +405,17 @@ impl DerivationPath {
405405

406406
/// Get an [Iterator] over the children of this [DerivationPath]
407407
/// starting with the given [ChildNumber].
408-
pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator {
408+
pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> {
409409
DerivationPathIterator::start_from(self, cn)
410410
}
411411

412412
/// Get an [Iterator] over the unhardened children of this [DerivationPath].
413-
pub fn normal_children(&self) -> DerivationPathIterator {
413+
pub fn normal_children(&self) -> DerivationPathIterator<'_> {
414414
DerivationPathIterator::start_from(self, ChildNumber::Normal { index: 0 })
415415
}
416416

417417
/// Get an [Iterator] over the hardened children of this [DerivationPath].
418-
pub fn hardened_children(&self) -> DerivationPathIterator {
418+
pub fn hardened_children(&self) -> DerivationPathIterator<'_> {
419419
DerivationPathIterator::start_from(self, ChildNumber::Hardened { index: 0 })
420420
}
421421

bitcoin/src/blockdata/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ mod test {
261261
use hex::test_hex_unwrap as hex;
262262

263263
use super::*;
264-
use crate::consensus::params;
265264
use crate::consensus::encode::serialize;
265+
use crate::consensus::params;
266266

267267
#[test]
268268
fn bitcoin_genesis_first_transaction() {

bitcoin/src/blockdata/locktime/absolute.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub use units::locktime::absolute::{
4242
/// consensus encoding to order it. We also implement [`ordered::ArbitraryOrd`] if the "ordered"
4343
/// feature is enabled.
4444
///
45+
/// [`ordered::ArbitraryOrd`]: <https://docs.rs/ordered/latest/ordered/trait.ArbitraryOrd.html>
46+
///
4547
/// ### Relevant BIPs
4648
///
4749
/// * [BIP-65 OP_CHECKLOCKTIMEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)
@@ -297,25 +299,19 @@ impl FromStr for LockTime {
297299
impl TryFrom<&str> for LockTime {
298300
type Error = ParseIntError;
299301

300-
fn try_from(s: &str) -> Result<Self, Self::Error> {
301-
LockTime::from_str(s)
302-
}
302+
fn try_from(s: &str) -> Result<Self, Self::Error> { LockTime::from_str(s) }
303303
}
304304

305305
impl TryFrom<String> for LockTime {
306306
type Error = ParseIntError;
307307

308-
fn try_from(s: String) -> Result<Self, Self::Error> {
309-
LockTime::from_str(&s)
310-
}
308+
fn try_from(s: String) -> Result<Self, Self::Error> { LockTime::from_str(&s) }
311309
}
312310

313311
impl TryFrom<Box<str>> for LockTime {
314312
type Error = ParseIntError;
315313

316-
fn try_from(s: Box<str>) -> Result<Self, Self::Error> {
317-
LockTime::from_str(&s)
318-
}
314+
fn try_from(s: Box<str>) -> Result<Self, Self::Error> { LockTime::from_str(&s) }
319315
}
320316

321317
impl From<Height> for LockTime {

bitcoin/src/blockdata/locktime/relative.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ pub use units::locktime::relative::{Height, Time, TimeOverflowError};
3030
///
3131
/// Locktimes may be height- or time-based, and these metrics are incommensurate; there is no total
3232
/// ordering on locktimes. We therefore have implemented [`PartialOrd`] but not [`Ord`]. We also
33-
/// implement [`ordered::ArbitraryOrd`] if the "ordered" feature is enabled.
33+
/// implement [`ordered::ArbitraryOrd`].
34+
///
35+
/// [`ordered::ArbitraryOrd`]: <https://docs.rs/ordered/latest/ordered/trait.ArbitraryOrd.html>
3436
///
3537
/// ### Relevant BIPs
3638
///

bitcoin/src/blockdata/script/borrowed.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl Script {
547547
///
548548
/// To force minimal pushes, use [`instructions_minimal`](Self::instructions_minimal).
549549
#[inline]
550-
pub fn instructions(&self) -> Instructions {
550+
pub fn instructions(&self) -> Instructions<'_> {
551551
Instructions { data: self.0.iter(), enforce_minimal: false }
552552
}
553553

@@ -556,7 +556,7 @@ impl Script {
556556
/// This is similar to [`instructions`](Self::instructions) but an error is returned if a push
557557
/// is not minimal.
558558
#[inline]
559-
pub fn instructions_minimal(&self) -> Instructions {
559+
pub fn instructions_minimal(&self) -> Instructions<'_> {
560560
Instructions { data: self.0.iter(), enforce_minimal: true }
561561
}
562562

@@ -568,7 +568,7 @@ impl Script {
568568
///
569569
/// To force minimal pushes, use [`Self::instruction_indices_minimal`].
570570
#[inline]
571-
pub fn instruction_indices(&self) -> InstructionIndices {
571+
pub fn instruction_indices(&self) -> InstructionIndices<'_> {
572572
InstructionIndices::from_instructions(self.instructions())
573573
}
574574

@@ -577,7 +577,7 @@ impl Script {
577577
/// This is similar to [`instruction_indices`](Self::instruction_indices) but an error is
578578
/// returned if a push is not minimal.
579579
#[inline]
580-
pub fn instruction_indices_minimal(&self) -> InstructionIndices {
580+
pub fn instruction_indices_minimal(&self) -> InstructionIndices<'_> {
581581
InstructionIndices::from_instructions(self.instructions_minimal())
582582
}
583583

bitcoin/src/blockdata/script/instruction.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ impl<'a> Instruction<'a> {
4545
_ => None,
4646
}
4747
}
48-
Instruction::PushBytes(bytes) => {
49-
match super::read_scriptint_non_minimal(bytes.as_bytes()) {
50-
Ok(v) => Some(v),
51-
_ => None,
52-
}
53-
}
48+
Instruction::PushBytes(bytes) =>
49+
super::read_scriptint_non_minimal(bytes.as_bytes()).ok(),
5450
}
5551
}
5652

bitcoin/src/blockdata/script/witness_program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub const MIN_SIZE: usize = 2;
2525
pub const MAX_SIZE: usize = 40;
2626

2727
/// The P2A program which is given by 0x4e73.
28-
pub(crate) const P2A_PROGRAM: [u8;2] = [78, 115];
28+
pub(crate) const P2A_PROGRAM: [u8; 2] = [78, 115];
2929

3030
/// The segregated witness program.
3131
///

bitcoin/src/blockdata/transaction.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! This module provides the structures and functions needed to support transactions.
1212
//!
1313
14-
use core::{cmp, fmt};
1514
use core::str::FromStr;
15+
use core::{cmp, fmt};
1616

1717
use hashes::{sha256d, Hash};
1818
use internals::write_err;
@@ -539,25 +539,19 @@ impl FromStr for Sequence {
539539
impl TryFrom<&str> for Sequence {
540540
type Error = ParseIntError;
541541

542-
fn try_from(s: &str) -> Result<Self, Self::Error> {
543-
Sequence::from_str(s)
544-
}
542+
fn try_from(s: &str) -> Result<Self, Self::Error> { Sequence::from_str(s) }
545543
}
546544

547545
impl TryFrom<String> for Sequence {
548546
type Error = ParseIntError;
549547

550-
fn try_from(s: String) -> Result<Self, Self::Error> {
551-
Sequence::from_str(&s)
552-
}
548+
fn try_from(s: String) -> Result<Self, Self::Error> { Sequence::from_str(&s) }
553549
}
554550

555551
impl TryFrom<Box<str>> for Sequence {
556552
type Error = ParseIntError;
557553

558-
fn try_from(s: Box<str>) -> Result<Self, Self::Error> {
559-
Sequence::from_str(&s)
560-
}
554+
fn try_from(s: Box<str>) -> Result<Self, Self::Error> { Sequence::from_str(&s) }
561555
}
562556

563557
/// Bitcoin transaction output.
@@ -1020,11 +1014,7 @@ impl Transaction {
10201014
1
10211015
} else if witness_program.is_p2wsh() {
10221016
// Treat the last item of the witness as the witnessScript
1023-
return witness
1024-
.last()
1025-
.map(Script::from_bytes)
1026-
.map(|s| s.count_sigops())
1027-
.unwrap_or(0);
1017+
witness.last().map(Script::from_bytes).map(|s| s.count_sigops()).unwrap_or(0)
10281018
} else {
10291019
0
10301020
}

0 commit comments

Comments
 (0)