Skip to content

Commit

Permalink
Merge rust-bitcoin#3233: Automated nightly rustfmt (2024-08-25)
Browse files Browse the repository at this point in the history
fbf7f41 2024-08-25 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  apoelstra:
    ACK fbf7f41 successfully ran local tests

Tree-SHA512: 2612a860db6e900558d840d2bd9f1a1f6d7d5fff823b2686613aecad84268c2d0f9cb024d023f91d010652aecf0b7b7e36eb00c930a601121e61a30bfc5ddd35
  • Loading branch information
apoelstra committed Aug 25, 2024
2 parents 51af258 + fbf7f41 commit 1058cbb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bitcoin/src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use io::{BufRead, Write};
use crate::consensus::encode::{Error, MAX_VEC_SIZE};
use crate::consensus::{Decodable, Encodable, WriteExt};
use crate::crypto::ecdsa;
use crate::prelude::{Vec, String};
use crate::prelude::{String, Vec};
#[cfg(doc)]
use crate::script::ScriptExt as _;
use crate::taproot::{self, TAPROOT_ANNEX_PREFIX};
Expand Down
8 changes: 2 additions & 6 deletions bitcoin/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,8 @@ mod tests {
#[cfg(feature = "serde")]
fn serde_roundtrip() {
use Network::*;
let tests = [
(Bitcoin, "bitcoin"),
(Testnet, "testnet"),
(Signet, "signet"),
(Regtest, "regtest"),
];
let tests =
[(Bitcoin, "bitcoin"), (Testnet, "testnet"), (Signet, "signet"), (Regtest, "regtest")];

for tc in tests {
let network = tc.0;
Expand Down
2 changes: 1 addition & 1 deletion bitcoin/src/taproot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::cmp::Reverse;
use core::fmt;
use core::iter::FusedIterator;

use hashes::{hash_newtype, sha256t_tag, sha256t, HashEngine};
use hashes::{hash_newtype, sha256t, sha256t_tag, HashEngine};
use internals::write_err;
use io::Write;
use secp256k1::{Scalar, Secp256k1};
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ macro_rules! hash_type {
<Self as crate::GeneralHash>::hash_reader(reader)
}
}
}
};
}
pub(crate) use hash_type;

Expand Down
20 changes: 16 additions & 4 deletions internals/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fn main() {

let out_dir = std::env::var_os("OUT_DIR").expect("missing OUT_DIR env var");
let out_dir = std::path::PathBuf::from(out_dir);
let macro_file = std::fs::File::create(out_dir.join("rust_version.rs")).expect("failed to create rust_version.rs");
let macro_file = std::fs::File::create(out_dir.join("rust_version.rs"))
.expect("failed to create rust_version.rs");
let macro_file = io::BufWriter::new(macro_file);
write_macro(macro_file, msrv_minor, minor).expect("failed to write to rust_version.rs");
}
Expand All @@ -63,17 +64,28 @@ fn write_macro(mut macro_file: impl io::Write, msrv_minor: u64, minor: u64) -> i
// These two loops are the magic; we output the clause if_yes/if_no
// dependent on the current compiler version (`minor`).
for version in msrv_minor..=minor {
writeln!(macro_file, " (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{", version)?;
writeln!(
macro_file,
" (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{",
version
)?;
writeln!(macro_file, " $($if_yes)*")?;
writeln!(macro_file, " }};")?;
}
for version in (minor + 1)..(MAX_USED_VERSION + 1) {
writeln!(macro_file, " (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{", version)?;
writeln!(
macro_file,
" (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{",
version
)?;
writeln!(macro_file, " $($($if_no)*)?")?;
writeln!(macro_file, " }};")?;
}
writeln!(macro_file, " (if >= $unknown:tt $($rest:tt)*) => {{")?;
writeln!(macro_file, " compile_error!(concat!(\"unknown Rust version \", stringify!($unknown)));")?;
writeln!(
macro_file,
" compile_error!(concat!(\"unknown Rust version \", stringify!($unknown)));"
)?;
writeln!(macro_file, " }};")?;
writeln!(macro_file, "}}")?;
writeln!(macro_file, "pub use rust_version;")?;
Expand Down
1 change: 1 addition & 0 deletions io/src/bridge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[cfg(feature = "alloc")]
use alloc::boxed::Box;

use internals::rust_version;

/// A bridging wrapper providing the IO traits for types that already implement `std` IO traits.
Expand Down
28 changes: 7 additions & 21 deletions io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,18 @@ impl<'a, R: BufRead + ?Sized> BufRead for Take<'a, R> {

impl<T: Read> Read for &'_ mut T {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
(**self).read(buf)
}
fn read(&mut self, buf: &mut [u8]) -> Result<usize> { (**self).read(buf) }

#[inline]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> {
(**self).read_exact(buf)
}
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> { (**self).read_exact(buf) }
}

impl<T: BufRead> BufRead for &'_ mut T {
#[inline]
fn fill_buf(&mut self) -> Result<&[u8]> {
(**self).fill_buf()
}
fn fill_buf(&mut self) -> Result<&[u8]> { (**self).fill_buf() }

#[inline]
fn consume(&mut self, amount: usize) {
(**self).consume(amount)
}
fn consume(&mut self, amount: usize) { (**self).consume(amount) }
}

impl Read for &[u8] {
Expand Down Expand Up @@ -285,19 +277,13 @@ pub trait Write {

impl<T: Write> Write for &'_ mut T {
#[inline]
fn write(&mut self, buf: &[u8]) -> Result<usize> {
(**self).write(buf)
}
fn write(&mut self, buf: &[u8]) -> Result<usize> { (**self).write(buf) }

#[inline]
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
(**self).write_all(buf)
}
fn write_all(&mut self, buf: &[u8]) -> Result<()> { (**self).write_all(buf) }

#[inline]
fn flush(&mut self) -> Result<()> {
(**self).flush()
}
fn flush(&mut self) -> Result<()> { (**self).flush() }
}

#[cfg(feature = "alloc")]
Expand Down

0 comments on commit 1058cbb

Please sign in to comment.