Skip to content

Commit 853abc7

Browse files
Fmt Botgithub-actions[bot]
authored andcommitted
2026-01-04 automated rustfmt nightly
1 parent 4f9301e commit 853abc7

8 files changed

Lines changed: 57 additions & 44 deletions

File tree

‎bitcoin/src/consensus/encode.rs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ impl_int_encodable!(i32, read_i32, emit_i32);
351351
impl_int_encodable!(i64, read_i64, emit_i64);
352352

353353
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1), and 9 otherwise.
354-
#[deprecated(since = "0.33.0", note = "use `consensus_encoding::CompactSizeEncoder::encoded_size` instead")]
354+
#[deprecated(
355+
since = "0.33.0",
356+
note = "use `consensus_encoding::CompactSizeEncoder::encoded_size` instead"
357+
)]
355358
#[inline]
356359
pub const fn varint_size_u64(v: u64) -> usize {
357360
const LIMIT: u64 = if core::mem::size_of::<usize>() <= 8 {
@@ -360,15 +363,19 @@ pub const fn varint_size_u64(v: u64) -> usize {
360363
u64::MAX
361364
};
362365

363-
#[allow(unreachable_patterns)] // Disable lint because this match is reachable on < 64 bit platforms
366+
#[allow(unreachable_patterns)]
367+
// Disable lint because this match is reachable on < 64 bit platforms
364368
match v {
365369
0..=LIMIT => encoding::CompactSizeEncoder::encoded_size(v as usize), // cast is ok because we just checked bounds
366370
_ => encoding::CompactSizeEncoder::encoded_size(usize::MAX),
367371
}
368372
}
369373

370374
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1), and 9 otherwise.
371-
#[deprecated(since = "0.33.0", note = "use `consensus_encoding::CompactSizeEncoder::encoded_size` instead")]
375+
#[deprecated(
376+
since = "0.33.0",
377+
note = "use `consensus_encoding::CompactSizeEncoder::encoded_size` instead"
378+
)]
372379
#[inline]
373380
pub fn varint_size(v: impl ToU64) -> usize {
374381
encoding::CompactSizeEncoder::encoded_size(v.to_u64().try_into().unwrap_or(usize::MAX))

‎consensus_encoding/src/decode/decoders.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ impl Decoder for ByteVecDecoder {
107107

108108
fn end(self) -> Result<Self::Output, Self::Error> {
109109
use {ByteVecDecoderError as E, ByteVecDecoderErrorInner as Inner};
110-
111-
if let Some(ref prefix_decoder) = self.prefix_decoder {
110+
111+
if let Some(ref prefix_decoder) = self.prefix_decoder {
112112
return Err(E(Inner::UnexpectedEof(UnexpectedEofError {
113-
missing: prefix_decoder.read_limit(),
113+
missing: prefix_decoder.read_limit(),
114114
})));
115115
}
116116

@@ -1221,7 +1221,7 @@ mod tests {
12211221
let data = [];
12221222
let _ = decoder.push_bytes(&mut data.as_slice());
12231223
let err = decoder.end().unwrap_err();
1224-
1224+
12251225
if let ByteVecDecoderErrorInner::UnexpectedEof(e) = err.0 {
12261226
assert_eq!(e.missing, 1);
12271227
} else {
@@ -1251,7 +1251,7 @@ mod tests {
12511251
let data = [0xFE];
12521252
let _ = decoder.push_bytes(&mut data.as_slice());
12531253
let err = decoder.end().unwrap_err();
1254-
1254+
12551255
if let ByteVecDecoderErrorInner::UnexpectedEof(e) = err.0 {
12561256
assert_eq!(e.missing, 4);
12571257
} else {
@@ -1266,7 +1266,7 @@ mod tests {
12661266
let data = [0xFF];
12671267
let _ = decoder.push_bytes(&mut data.as_slice());
12681268
let err = decoder.end().unwrap_err();
1269-
1269+
12701270
if let ByteVecDecoderErrorInner::UnexpectedEof(e) = err.0 {
12711271
assert_eq!(e.missing, 8);
12721272
} else {

‎consensus_encoding/src/encode/encoders.rs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//! For implementing these newtypes, we provide the [`encoder_newtype`] macro.
1212
//!
1313
14-
use super::{Encodable, Encoder};
15-
1614
use internals::array_vec::ArrayVec;
1715

16+
use super::{Encodable, Encoder};
17+
1818
/// The maximum length of a compact size encoding.
1919
const SIZE: usize = 9;
2020

@@ -231,9 +231,7 @@ impl CompactSizeEncoder {
231231
/// values. In such cases we will ignore the passed value and encode [`u64::MAX`].
232232
/// But even on such exotic systems, we expect users to pass the length of an
233233
/// in-memory object, meaning that such large values are impossible to obtain.
234-
pub fn new(value: usize) -> Self {
235-
Self { buf: Some(Self::encode(value)) }
236-
}
234+
pub fn new(value: usize) -> Self { Self { buf: Some(Self::encode(value)) } }
237235

238236
/// Returns the number of bytes used to encode this `CompactSize` value.
239237
///

‎primitives/src/block.rs‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,20 +1187,18 @@ mod tests {
11871187
};
11881188

11891189
let block: u32 = 741_521;
1190-
let transactions = vec![
1191-
Transaction {
1192-
version: crate::transaction::Version::ONE,
1193-
lock_time: units::absolute::LockTime::from_height(block).unwrap(),
1194-
inputs: vec![crate::transaction::TxIn {
1195-
previous_output: crate::transaction::OutPoint::COINBASE_PREVOUT,
1196-
// Coinbase scriptSig must be 2-100 bytes
1197-
script_sig: crate::script::ScriptSigBuf::from_bytes(vec![0x51, 0x51]),
1198-
sequence: crate::sequence::Sequence::MAX,
1199-
witness: crate::witness::Witness::new(),
1200-
}],
1201-
outputs: Vec::new(),
1202-
},
1203-
];
1190+
let transactions = vec![Transaction {
1191+
version: crate::transaction::Version::ONE,
1192+
lock_time: units::absolute::LockTime::from_height(block).unwrap(),
1193+
inputs: vec![crate::transaction::TxIn {
1194+
previous_output: crate::transaction::OutPoint::COINBASE_PREVOUT,
1195+
// Coinbase scriptSig must be 2-100 bytes
1196+
script_sig: crate::script::ScriptSigBuf::from_bytes(vec![0x51, 0x51]),
1197+
sequence: crate::sequence::Sequence::MAX,
1198+
witness: crate::witness::Witness::new(),
1199+
}],
1200+
outputs: Vec::new(),
1201+
}];
12041202
let original_block = Block::new_unchecked(header, transactions);
12051203

12061204
// Encode + decode the block

‎primitives/src/transaction.rs‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,12 @@ impl fmt::Display for TransactionDecoderError {
716716
E::NoWitnesses => write!(f, "non-empty Segwit transaction with no witnesses"),
717717
E::LockTime(ref e) => write_err!(f, "transaction decoder error"; e),
718718
E::EarlyEnd(s) => write!(f, "early end of transaction (still decoding {})", s),
719-
E::NullPrevoutInNonCoinbase(index) => write!(f, "null prevout in non-coinbase transaction at input {}", index),
720-
E::CoinbaseScriptSigTooSmall(len) => write!(f, "coinbase scriptSig too small: {} bytes (min 2)", len),
721-
E::CoinbaseScriptSigTooLarge(len) => write!(f, "coinbase scriptSig too large: {} bytes (max 100)", len),
719+
E::NullPrevoutInNonCoinbase(index) =>
720+
write!(f, "null prevout in non-coinbase transaction at input {}", index),
721+
E::CoinbaseScriptSigTooSmall(len) =>
722+
write!(f, "coinbase scriptSig too small: {} bytes (min 2)", len),
723+
E::CoinbaseScriptSigTooLarge(len) =>
724+
write!(f, "coinbase scriptSig too large: {} bytes (max 100)", len),
722725
}
723726
}
724727
}
@@ -2240,7 +2243,10 @@ mod tests {
22402243
decoder.push_bytes(&mut slice).unwrap();
22412244
let err = decoder.end().expect_err("null prevout in non-coinbase tx should be rejected");
22422245

2243-
assert_eq!(err, TransactionDecoderError(TransactionDecoderErrorInner::NullPrevoutInNonCoinbase(0)));
2246+
assert_eq!(
2247+
err,
2248+
TransactionDecoderError(TransactionDecoderErrorInner::NullPrevoutInNonCoinbase(0))
2249+
);
22442250
}
22452251

22462252
#[test]
@@ -2256,7 +2262,10 @@ mod tests {
22562262
decoder.push_bytes(&mut slice).unwrap();
22572263
let err = decoder.end().expect_err("coinbase with 1-byte scriptSig should be rejected");
22582264

2259-
assert_eq!(err, TransactionDecoderError(TransactionDecoderErrorInner::CoinbaseScriptSigTooSmall(1)));
2265+
assert_eq!(
2266+
err,
2267+
TransactionDecoderError(TransactionDecoderErrorInner::CoinbaseScriptSigTooSmall(1))
2268+
);
22602269
}
22612270

22622271
#[test]
@@ -2272,7 +2281,10 @@ mod tests {
22722281
decoder.push_bytes(&mut slice).unwrap();
22732282
let err = decoder.end().expect_err("coinbase with 101-byte scriptSig should be rejected");
22742283

2275-
assert_eq!(err, TransactionDecoderError(TransactionDecoderErrorInner::CoinbaseScriptSigTooLarge(101)));
2284+
assert_eq!(
2285+
err,
2286+
TransactionDecoderError(TransactionDecoderErrorInner::CoinbaseScriptSigTooLarge(101))
2287+
);
22762288
}
22772289

22782290
#[test]

‎primitives/src/witness.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,15 +1093,15 @@ mod test {
10931093
#[test]
10941094
fn witness_size() {
10951095
let mut witness = Witness::new();
1096-
let want = 1; // Number of elements compact size encoded.
1096+
let want = 1; // Number of elements compact size encoded.
10971097
assert_eq!(witness.size(), want);
10981098

10991099
witness.push([1, 2, 3]);
1100-
let want = 5; // 1 + 1 + 3
1100+
let want = 5; // 1 + 1 + 3
11011101
assert_eq!(witness.size(), want);
11021102

11031103
witness.push([4, 5]);
1104-
let want = 8; // 5 + 1 + 2
1104+
let want = 8; // 5 + 1 + 2
11051105
assert_eq!(witness.size(), want);
11061106
}
11071107

‎units/src/block.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,10 @@ impl<'a> core::iter::Sum<&'a Self> for BlockMtpInterval {
597597

598598
#[cfg(test)]
599599
mod tests {
600-
use super::*;
601-
602600
#[cfg(feature = "encoding")]
603601
use encoding::{Decodable as _, Decoder as _, UnexpectedEofError};
604602

603+
use super::*;
605604
use crate::relative::{NumberOf512Seconds, TimeOverflowError};
606605

607606
#[test]
@@ -756,7 +755,6 @@ mod tests {
756755
);
757756
}
758757

759-
760758
#[test]
761759
fn block_mtp_interval_to_relative_mtp_ceil() {
762760
let time = NumberOf512Seconds::from_512_second_intervals(0);

‎units/src/sequence.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,12 @@ mod tests {
392392
#[cfg(feature = "alloc")]
393393
use alloc::format;
394394

395-
use super::*;
396-
397-
#[cfg(feature = "encoding")]
398-
use encoding::{Decodable as _, Decoder as _};
399395
#[cfg(all(feature = "encoding", feature = "alloc"))]
400396
use encoding::UnexpectedEofError;
397+
#[cfg(feature = "encoding")]
398+
use encoding::{Decodable as _, Decoder as _};
399+
400+
use super::*;
401401

402402
const MAXIMUM_ENCODABLE_SECONDS: u32 = u16::MAX as u32 * 512;
403403

0 commit comments

Comments
 (0)