Skip to content

Commit 0cffca2

Browse files
Fmt Botgithub-actions[bot]
Fmt Bot
authored andcommitted
2025-03-16 automated rustfmt nightly
1 parent 0ca9fcf commit 0cffca2

File tree

24 files changed

+87
-91
lines changed

24 files changed

+87
-91
lines changed

bitcoin/src/bip152.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ mod test {
413413
use crate::merkle_tree::TxMerkleNode;
414414
use crate::transaction::OutPointExt;
415415
use crate::{
416-
transaction, Amount, BlockChecked, CompactTarget, OutPoint, ScriptBuf, Sequence, BlockTime,
416+
transaction, Amount, BlockChecked, BlockTime, CompactTarget, OutPoint, ScriptBuf, Sequence,
417417
TxIn, TxOut, Txid, Witness,
418418
};
419419

bitcoin/src/blockdata/constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::opcodes::all::*;
1616
use crate::pow::CompactTarget;
1717
use crate::transaction::{self, OutPoint, Transaction, TxIn, TxOut};
1818
use crate::witness::Witness;
19-
use crate::{script, Amount, BlockHash, Sequence, TestnetVersion, BlockTime};
19+
use crate::{script, Amount, BlockHash, BlockTime, Sequence, TestnetVersion};
2020

2121
/// How many seconds between blocks we expect on average.
2222
pub const TARGET_BLOCK_SPACING: u32 = 600;

bitcoin/src/blockdata/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ pub use self::{
2121

2222
/// Implements `FeeRate` and assoctiated features.
2323
pub mod fee_rate {
24-
/// Re-export everything from the [`units::fee_rate`] module.
25-
pub use units::fee_rate::FeeRate;
2624
#[cfg(feature = "serde")]
2725
pub use units::fee_rate::serde;
26+
/// Re-export everything from the [`units::fee_rate`] module.
27+
pub use units::fee_rate::FeeRate;
2828
}
2929

3030
/// Provides absolute and relative locktimes.

bitcoin/src/blockdata/script/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::address::script_pubkey::{
88
};
99
use crate::consensus::encode::{deserialize, serialize};
1010
use crate::crypto::key::{PublicKey, XOnlyPublicKey};
11-
use crate::{Amount, FeeRate, opcodes};
11+
use crate::{opcodes, Amount, FeeRate};
1212

1313
#[test]
1414
#[rustfmt::skip]

bitcoin/src/crypto/key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl PrivateKey {
462462
/// Deserializes a private key from a byte array.
463463
pub fn from_byte_array(
464464
data: [u8; 32],
465-
network: impl Into<NetworkKind>
465+
network: impl Into<NetworkKind>,
466466
) -> Result<PrivateKey, secp256k1::Error> {
467467
Ok(PrivateKey::new(secp256k1::SecretKey::from_byte_array(&data)?, network))
468468
}

bitcoin/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ pub use crate::{
164164
blockdata::script::witness_program::{self, WitnessProgram},
165165
blockdata::script::witness_version::{self, WitnessVersion},
166166
// These modules also re-export all the respective `primitives` types.
167-
blockdata::{
168-
block, constants, fee_rate, locktime, script, transaction, weight, witness,
169-
},
167+
blockdata::{block, constants, fee_rate, locktime, script, transaction, weight, witness},
170168
};
171169

172170
#[rustfmt::skip]

bitcoin/src/psbt/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl Psbt {
135135
/// An alias for [`extract_tx_fee_rate_limit`].
136136
///
137137
/// [`extract_tx_fee_rate_limit`]: Psbt::extract_tx_fee_rate_limit
138-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
138+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
139139
pub fn extract_tx(self) -> Result<Transaction, ExtractTxError> {
140140
self.internal_extract_tx_with_fee_rate_limit(Self::DEFAULT_MAX_FEE_RATE)
141141
}
@@ -147,7 +147,7 @@ impl Psbt {
147147
/// [`ExtractTxError`] variants will contain either the [`Psbt`] itself or the [`Transaction`]
148148
/// that was extracted. These can be extracted from the Errors in order to recover.
149149
/// See the error documentation for info on the variants. In general, it covers large fees.
150-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
150+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
151151
pub fn extract_tx_fee_rate_limit(self) -> Result<Transaction, ExtractTxError> {
152152
self.internal_extract_tx_with_fee_rate_limit(Self::DEFAULT_MAX_FEE_RATE)
153153
}
@@ -159,7 +159,7 @@ impl Psbt {
159159
/// See [`extract_tx`].
160160
///
161161
/// [`extract_tx`]: Psbt::extract_tx
162-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
162+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
163163
pub fn extract_tx_with_fee_rate_limit(
164164
self,
165165
max_fee_rate: FeeRate,
@@ -187,7 +187,7 @@ impl Psbt {
187187
}
188188

189189
#[inline]
190-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
190+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
191191
fn internal_extract_tx_with_fee_rate_limit(
192192
self,
193193
max_fee_rate: FeeRate,

bitcoin/src/psbt/serialize.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@ impl Serialize for XOnlyPublicKey {
260260

261261
impl Deserialize for XOnlyPublicKey {
262262
fn deserialize(bytes: &[u8]) -> Result<Self, Error> {
263-
XOnlyPublicKey::from_byte_array(
264-
bytes.try_into().map_err(|_| Error::InvalidXOnlyPublicKey)?,
265-
)
266-
.map_err(|_| Error::InvalidXOnlyPublicKey)
263+
XOnlyPublicKey::from_byte_array(bytes.try_into().map_err(|_| Error::InvalidXOnlyPublicKey)?)
264+
.map_err(|_| Error::InvalidXOnlyPublicKey)
267265
}
268266
}
269267

bitcoin/src/taproot/merkle_branch.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ impl TaprootMerkleBranch {
5252
} else if node_hashes.len() > TAPROOT_CONTROL_MAX_NODE_COUNT {
5353
Err(InvalidMerkleTreeDepthError(sl.len() / TAPROOT_CONTROL_NODE_SIZE).into())
5454
} else {
55-
let inner = node_hashes
56-
.iter()
57-
.copied()
58-
.map(TapNodeHash::from_byte_array)
59-
.collect();
55+
let inner = node_hashes.iter().copied().map(TapNodeHash::from_byte_array).collect();
6056

6157
Ok(TaprootMerkleBranch(inner))
6258
}

bitcoin/tests/serde.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ fn serde_regression_txin() {
109109

110110
#[test]
111111
fn serde_regression_txout() {
112-
let txout =
113-
TxOut { value: Amount::MAX, script_pubkey: ScriptBuf::from(vec![0u8, 1u8, 2u8]) };
112+
let txout = TxOut { value: Amount::MAX, script_pubkey: ScriptBuf::from(vec![0u8, 1u8, 2u8]) };
114113
let got = serialize(&txout).unwrap();
115114
let want = include_bytes!("data/serde/txout_bincode") as &[_];
116115
assert_eq!(got, want)

fuzz/fuzz_targets/bitcoin/deserialize_psbt.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use honggfuzz::fuzz;
2-
31
use bitcoin_fuzz::fuzz_utils::consume_random_bytes;
2+
use honggfuzz::fuzz;
43

54
fn do_test(data: &[u8]) {
65
let mut new_data = data;

fuzz/fuzz_targets/bitcoin/deserialize_script.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use bitcoin::address::Address;
22
use bitcoin::consensus::encode;
33
use bitcoin::script::{self, ScriptExt as _};
44
use bitcoin::{FeeRate, Network};
5-
use honggfuzz::fuzz;
6-
75
use bitcoin_fuzz::fuzz_utils::{consume_random_bytes, consume_u64};
6+
use honggfuzz::fuzz;
87

98
fn do_test(data: &[u8]) {
109
let mut new_data = data;

hashes/src/ripemd160/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
#[cfg(feature = "small-hash")]

hashes/src/sha1/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
impl HashEngine {

hashes/src/sha256/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use core::arch::x86::*;
66
use core::arch::x86_64::*;
77

88
use internals::slice::SliceExt;
9+
910
use super::{HashEngine, Midstate, BLOCK_SIZE};
1011

1112
#[allow(non_snake_case)]

hashes/src/sha256/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod crypto;
99
mod tests;
1010

1111
use core::{cmp, convert, fmt};
12+
1213
use internals::slice::SliceExt;
1314

1415
use crate::{incomplete_block_len, sha256d, HashEngine as _};
@@ -80,7 +81,8 @@ impl HashEngine {
8081
/// Please see docs on [`Midstate`] before using this function.
8182
pub fn from_midstate(midstate: Midstate) -> HashEngine {
8283
let mut ret = [0; 8];
83-
for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate.as_ref().bitcoin_as_chunks().0) {
84+
for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate.as_ref().bitcoin_as_chunks().0)
85+
{
8486
*ret_val = u32::from_be_bytes(*midstate_bytes);
8587
}
8688

hashes/src/sha512/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
#[allow(non_snake_case)]

internals/src/slice.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub trait SliceExt {
2323
/// let mut slice = [1, 2, 3];
2424
/// let fail = slice.as_chunks_mut::<0>();
2525
/// ```
26-
fn bitcoin_as_chunks_mut<const N: usize>(&mut self) -> (&mut [[Self::Item; N]], &mut [Self::Item]);
26+
fn bitcoin_as_chunks_mut<const N: usize>(
27+
&mut self,
28+
) -> (&mut [[Self::Item; N]], &mut [Self::Item]);
2729
}
2830

2931
impl<T> SliceExt for [T] {
@@ -40,11 +42,15 @@ impl<T> SliceExt for [T] {
4042
// we're merely casting, so no aliasing issues here
4143
// arrays of T have same alignment as T
4244
// the resulting slice points within the obtained slice as was computed above
43-
let left = unsafe { core::slice::from_raw_parts(left.as_ptr().cast::<[Self::Item; N]>(), chunks_count) };
45+
let left = unsafe {
46+
core::slice::from_raw_parts(left.as_ptr().cast::<[Self::Item; N]>(), chunks_count)
47+
};
4448
(left, right)
4549
}
4650

47-
fn bitcoin_as_chunks_mut<const N: usize>(&mut self) -> (&mut [[Self::Item; N]], &mut [Self::Item]) {
51+
fn bitcoin_as_chunks_mut<const N: usize>(
52+
&mut self,
53+
) -> (&mut [[Self::Item; N]], &mut [Self::Item]) {
4854
#[allow(clippy::let_unit_value)]
4955
let _ = Hack::<N>::IS_NONZERO;
5056

@@ -55,15 +61,22 @@ impl<T> SliceExt for [T] {
5561
// we're merely casting, so no aliasing issues here
5662
// arrays of T have same alignment as T
5763
// the resulting slice points within the obtained slice as was computed above
58-
let left = unsafe { core::slice::from_raw_parts_mut(left.as_mut_ptr().cast::<[Self::Item; N]>(), chunks_count) };
64+
let left = unsafe {
65+
core::slice::from_raw_parts_mut(
66+
left.as_mut_ptr().cast::<[Self::Item; N]>(),
67+
chunks_count,
68+
)
69+
};
5970
(left, right)
6071
}
6172
}
6273

6374
struct Hack<const N: usize>;
6475

6576
impl<const N: usize> Hack<N> {
66-
const IS_NONZERO: () = { assert!(N != 0); };
77+
const IS_NONZERO: () = {
78+
assert!(N != 0);
79+
};
6780
}
6881

6982
#[cfg(test)]

primitives/src/opcodes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! all of the opcodes for that language.
77
88
#![allow(non_camel_case_types)]
9-
#![allow(dead_code)] // This module is private and is duplicated in `bitcoin`.
9+
#![allow(dead_code)] // This module is private and is duplicated in `bitcoin`.
1010

1111
use core::fmt;
1212

primitives/src/transaction.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,10 @@ mod tests {
670670
witness: Witness::new(),
671671
};
672672

673-
let txout = TxOut { value: Amount::from_sat(123_456_789).unwrap(), script_pubkey: ScriptBuf::new() };
673+
let txout = TxOut {
674+
value: Amount::from_sat(123_456_789).unwrap(),
675+
script_pubkey: ScriptBuf::new(),
676+
};
674677

675678
let tx_orig = Transaction {
676679
version: Version::ONE,

primitives/src/witness.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ impl<'de> serde::Deserialize<'de> for Witness {
355355
self,
356356
mut a: A,
357357
) -> Result<Self::Value, A::Error> {
358-
use hex::FromHex;
359-
use hex::HexToBytesError as E;
358+
use hex::{FromHex, HexToBytesError as E};
360359
use serde::de::{self, Unexpected};
361360

362361
let mut ret = match a.size_hint() {
@@ -366,16 +365,17 @@ impl<'de> serde::Deserialize<'de> for Witness {
366365

367366
while let Some(elem) = a.next_element::<String>()? {
368367
let vec = Vec::<u8>::from_hex(&elem).map_err(|e| match e {
369-
E::InvalidChar(ref e) => match core::char::from_u32(e.invalid_char().into()) {
370-
Some(c) => de::Error::invalid_value(
371-
Unexpected::Char(c),
372-
&"a valid hex character",
373-
),
374-
None => de::Error::invalid_value(
375-
Unexpected::Unsigned(e.invalid_char().into()),
376-
&"a valid hex character",
377-
),
378-
},
368+
E::InvalidChar(ref e) =>
369+
match core::char::from_u32(e.invalid_char().into()) {
370+
Some(c) => de::Error::invalid_value(
371+
Unexpected::Char(c),
372+
&"a valid hex character",
373+
),
374+
None => de::Error::invalid_value(
375+
Unexpected::Unsigned(e.invalid_char().into()),
376+
&"a valid hex character",
377+
),
378+
},
379379
E::OddLengthString(ref e) =>
380380
de::Error::invalid_length(e.length(), &"an even length string"),
381381
})?;

units/src/amount/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Denomination {
115115
Denomination::MicroBitcoin => -2,
116116
Denomination::Bit => -2,
117117
Denomination::Satoshi => 0,
118-
Denomination::_DoNotUse(infallible) => match infallible {}
118+
Denomination::_DoNotUse(infallible) => match infallible {},
119119
}
120120
}
121121

@@ -128,7 +128,7 @@ impl Denomination {
128128
Denomination::MicroBitcoin => "uBTC",
129129
Denomination::Bit => "bits",
130130
Denomination::Satoshi => "satoshi",
131-
Denomination::_DoNotUse(infallible) => match infallible {}
131+
Denomination::_DoNotUse(infallible) => match infallible {},
132132
}
133133
}
134134

0 commit comments

Comments
 (0)