Merge rust-bitcoin/rust-bitcoin#2188: Bump MSRV to Rust version 1.56.1

761de886be Remove imports of TryFrom and TryInto (Tobin C. Harding)
4d5415f835 Add rust-version to the workspace manifests (Tobin C. Harding)
a41e978855 Update to edition 2021 (Tobin C. Harding)
d9cc724187 Bump MSRV to Rust version 1.56.1 (Tobin C. Harding)

Pull request description:

  Rust version 1.56.0 introduced edition 2021. Shortly afterwards, on October 21 2021 Rust version 1.56.1 was released.

  Debian stable is currently shipping `rustc 1.63.0`. Our stated MSRV policy is: In Debian stable and at least 2 years old. Therefore our MSRV policy is met by Rust version 1.56.1 and we can strat to bump our MSRV org wide. Start by bumping the `rust-bitcoin` and `hashes` MSRV to Rust 1.56.1

  Start by bumping the `rust-bitcoin` and `hashes` MSRV to Rust 1.56.1, includes:

  - Update docs.
  - Update CI and remove pinning.
  - Update the build files and remove now stale cfg attributes rust_v_1_x for values less than the new MSRV.
  - Use new `IntoIterator` for arrays so we no longer need to allocate a vector to iterate.

  Links:

  - https://blog.rust-lang.org/2021/11/01/Rust-1.56.1.html
  - https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
  - https://packages.debian.org/stable/rust/rustc

ACKs for top commit:
  Kixunil:
    ACK 761de886be
  apoelstra:
    ACK 761de886be

Tree-SHA512: 3a81c8bfa37d8cec0ec794f516f014da67ae8e437decf149c9681aa547885acac0ee07ea2c0f42e4f6bfd6f7ed1695fcf4747f53cc50e5f4e70ce3fe7bcba4e9
This commit is contained in:
Andrew Poelstra 2023-11-26 13:42:13 +00:00
commit 4806461c75
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
44 changed files with 40 additions and 89 deletions

View File

@ -66,7 +66,7 @@ jobs:
run: ./contrib/test.sh
MSRV:
name: Test - 1.48.0 toolchain
name: Test - 1.56.1 toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
@ -76,7 +76,7 @@ jobs:
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.48.0"
toolchain: "1.56.1"
- name: Running test script
env:
DO_FEATURE_MATRIX: true

View File

@ -1,5 +1,6 @@
[workspace]
members = ["bitcoin", "hashes", "internals", "fuzz", "io"]
resolver = "2"
[patch.crates-io.bitcoin]
path = "bitcoin"

View File

@ -12,7 +12,7 @@
<a href="https://github.com/rust-bitcoin/rust-bitcoin/blob/master/LICENSE"><img alt="CC0 1.0 Universal Licensed" src="https://img.shields.io/badge/license-CC0--1.0-blue.svg"/></a>
<a href="https://github.com/rust-bitcoin/rust-bitcoin/actions?query=workflow%3AContinuous%20integration"><img alt="CI Status" src="https://github.com/rust-bitcoin/rust-bitcoin/workflows/Continuous%20integration/badge.svg"></a>
<a href="https://docs.rs/bitcoin"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bitcoin-green"/></a>
<a href="https://blog.rust-lang.org/2020/02/27/Rust-1.48.0.html"><img alt="Rustc Version 1.48.0+" src="https://img.shields.io/badge/rustc-1.48.0%2B-lightgrey.svg"/></a>
<a href="https://blog.rust-lang.org/2020/02/27/Rust-1.56.1.html"><img alt="Rustc Version 1.56.1+" src="https://img.shields.io/badge/rustc-1.56.1%2B-lightgrey.svg"/></a>
<a href="https://gnusha.org/bitcoin-rust/"><img alt="Chat on IRC" src="https://img.shields.io/badge/irc-%23bitcoin--rust%20on%20libera.chat-blue"></a>
<a href="https://github.com/model-checking/kani"><imp alt="kani" src="https://github.com/rust-bitcoin/rust-bitcoin/actions/workflows/kani.yaml/badge.svg"></a>
</p>
@ -69,7 +69,7 @@ For more information please see `./CONTRIBUTING.md`.
## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.48.0**.
This library should always compile with any combination of features on **Rust 1.56.1**.
To build with the MSRV you will likely need to pin a bunch of dependencies, see `./contrib/test.sh`
for the current list.

View File

@ -1,3 +1,7 @@
# unreleased
- Bump MSRV to Rust 1.56.1
# 0.31.1 - 2023-10-18
- Bump MSRV to Rust 1.48.0 [#1729](https://github.com/rust-bitcoin/rust-bitcoin/pull/1729)

View File

@ -9,7 +9,8 @@ description = "General purpose library for using and interoperating with Bitcoin
categories = ["cryptography::cryptocurrencies"]
keywords = [ "crypto", "bitcoin" ]
readme = "../README.md"
edition = "2018"
edition = "2021"
rust-version = "1.56.1"
exclude = ["tests", "contrib"]
[features]

View File

@ -1,4 +1,4 @@
const MSRV_MINOR: u64 = 48;
const MSRV_MINOR: u64 = 56;
fn main() {
let rustc = std::env::var_os("RUSTC");

View File

@ -1,6 +1,6 @@
[package]
authors = ["Riccardo Casatta <riccardo@casatta.it>", "Dev Random <c1.devrandom@niftybox.net>"]
edition = "2018"
edition = "2021"
readme = "README.md"
name = "embedded"
version = "0.1.0"

View File

@ -6,7 +6,6 @@
//! strings respectively.
//!
use core::convert::TryInto;
use core::{fmt, iter, slice, str};
use hashes::{sha256d, Hash};

View File

@ -39,7 +39,6 @@
//!
use core::cmp::{self, Ordering};
use core::convert::TryInto;
use core::fmt::{self, Display, Formatter};
use hashes::{siphash24, Hash};

View File

@ -6,7 +6,6 @@
//! at <https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki>.
//!
use core::convert::TryInto;
use core::default::Default;
use core::ops::Index;
use core::str::FromStr;

View File

@ -374,14 +374,12 @@ impl<'de> serde::Deserialize<'de> for LockTime {
// calls visit_u64, even when called from Deserializer::deserialize_u32. The
// other visit_u*s have default implementations that forward to visit_u64.
fn visit_u64<E: serde::de::Error>(self, v: u64) -> Result<u32, E> {
use core::convert::TryInto;
v.try_into().map_err(|_| {
E::invalid_value(serde::de::Unexpected::Unsigned(v), &"a 32-bit number")
})
}
// Also do the signed version, just for good measure.
fn visit_i64<E: serde::de::Error>(self, v: i64) -> Result<u32, E> {
use core::convert::TryInto;
v.try_into().map_err(|_| {
E::invalid_value(serde::de::Unexpected::Signed(v), &"a 32-bit number")
})

View File

@ -6,7 +6,6 @@
//! whether bit 22 of the `u32` consensus value is set.
//!
use core::convert::TryFrom;
use core::fmt;
#[cfg(all(test, mutate))]

View File

@ -2,9 +2,9 @@
use core::convert::{TryFrom, TryInto};
use core::fmt;
#[cfg(rust_v_1_53)]
use core::ops::Bound;
use core::ops::{Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive};
use core::ops::{
Bound, Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
};
use hashes::Hash;
use secp256k1::{Secp256k1, Verification};
@ -653,7 +653,6 @@ delegate_index!(
RangeTo<usize>,
RangeFull,
RangeInclusive<usize>,
RangeToInclusive<usize>
RangeToInclusive<usize>,
(Bound<usize>, Bound<usize>)
);
#[cfg(rust_v_1_53)]
delegate_index!((Bound<usize>, Bound<usize>));

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
use core::convert::TryInto;
use crate::blockdata::opcodes::{self, Opcode};
use crate::blockdata::script::{read_uint_iter, Error, PushBytes, Script, ScriptBuf, UintError};

View File

@ -16,10 +16,8 @@ pub use self::primitive::*;
/// break invariants. Therefore auditing this module should be sufficient.
mod primitive {
use core::convert::{TryFrom, TryInto};
#[cfg(rust_v_1_53)]
use core::ops::Bound;
use core::ops::{
Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
Bound, Index, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
};
use super::PushBytesError;
@ -105,10 +103,9 @@ mod primitive {
RangeTo<usize>,
RangeFull,
RangeInclusive<usize>,
RangeToInclusive<usize>
RangeToInclusive<usize>,
(Bound<usize>, Bound<usize>)
);
#[cfg(rust_v_1_53)]
delegate_index!((Bound<usize>, Bound<usize>));
impl Index<usize> for PushBytes {
type Output = u8;

View File

@ -7,7 +7,6 @@
//!
//! [BIP141]: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki>
use core::convert::TryInto;
use core::fmt;
use crate::blockdata::script::witness_version::WitnessVersion;

View File

@ -7,7 +7,6 @@
//!
//! [BIP141]: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki>
use core::convert::TryFrom;
use core::fmt;
use core::str::FromStr;

View File

@ -11,7 +11,6 @@
//! This module provides the structures and functions needed to support transactions.
//!
use core::convert::TryFrom;
use core::default::Default;
use core::{cmp, fmt, str};

View File

@ -5,7 +5,6 @@
//! This module contains the [`Witness`] struct and related methods to operate on it
//!
use core::convert::TryInto;
use core::fmt;
use core::ops::Index;

View File

@ -18,7 +18,6 @@
//! assert_eq!(&bytes[..], &[0xF9, 0xBE, 0xB4, 0xD9]);
//! ```
use core::convert::TryFrom;
use core::fmt;
use core::fmt::Display;
use core::str::FromStr;

View File

@ -6,7 +6,6 @@
//! are used for (de)serializing Bitcoin objects for transmission on the network.
//!
use core::convert::TryFrom;
use core::{fmt, iter};
use hashes::{sha256d, Hash};

View File

@ -20,7 +20,6 @@ pub mod message_filter;
#[cfg(feature = "std")]
pub mod message_network;
use core::convert::TryFrom;
use core::str::FromStr;
use core::{fmt, ops};

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
use core::convert::TryFrom;
use core::fmt;
use core::str::FromStr;

View File

@ -834,8 +834,6 @@ impl crate::serde::Serialize for U256 {
#[cfg(feature = "serde")]
impl<'de> crate::serde::Deserialize<'de> for U256 {
fn deserialize<D: crate::serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
use core::convert::TryInto;
use hex::FromHex;
use crate::serde::de;

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
use core::convert::TryFrom;
use crate::bip32::{ChildNumber, DerivationPath, Fingerprint, Xpub};
use crate::blockdata::transaction::Transaction;
use crate::consensus::encode::MAX_VEC_SIZE;

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
use core::convert::TryFrom;
use core::fmt;
use core::str::FromStr;

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
use core::convert::TryFrom;
use secp256k1::XOnlyPublicKey;
use {core, secp256k1};

View File

@ -6,7 +6,6 @@
//! <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>.
//!
use core::convert::TryFrom;
use core::fmt;
use super::serialize::{Deserialize, Serialize};

View File

@ -6,8 +6,6 @@
//! according to the BIP-174 specification.
//!
use core::convert::{TryFrom, TryInto};
use hashes::{hash160, ripemd160, sha256, sha256d, Hash};
use secp256k1::{self, XOnlyPublicKey};
@ -386,8 +384,6 @@ fn key_source_len(key_source: &KeySource) -> usize { 4 + 4 * (key_source.1).as_r
#[cfg(test)]
mod tests {
use core::convert::TryFrom;
use super::*;
// Composes tree matching a given depth map, filled with dumb script leafs,

View File

@ -6,7 +6,6 @@
//!
use core::cmp::Reverse;
use core::convert::TryFrom;
use core::fmt;
use core::iter::FusedIterator;
@ -1845,7 +1844,7 @@ mod test {
let tree_info = builder.finalize(&secp, internal_key).unwrap();
let output_key = tree_info.output_key();
for script in vec![a, b, c, d, e] {
for script in [a, b, c, d, e] {
let ver_script = (script, LeafVersion::TapScript);
let ctrl_block = tree_info.control_block(&ver_script).unwrap();
assert!(ctrl_block.verify_taproot_commitment(

View File

@ -1,7 +1,6 @@
//! Tests PSBT integration vectors from BIP 174
//! defined at <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#test-vectors>
use core::convert::TryFrom;
use std::collections::BTreeMap;
use std::str::FromStr;

View File

@ -1,2 +1,2 @@
msrv = "1.48.0"
msrv = "1.56.1"
too-many-arguments-threshold = 13

View File

@ -4,22 +4,6 @@ set -ex
CRATES="bitcoin hashes internals fuzz"
DEPS="recent minimal"
MSRV="1\.48\.0"
# Test pinned versions.
if cargo --version | grep ${MSRV}; then
cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156
cargo update -p quote --precise 1.0.30
cargo update -p proc-macro2 --precise 1.0.63
cargo update -p serde_test --precise 1.0.175
cargo update -p schemars --precise 0.8.12
# byteorder 1.5.0 uses edition 2021
cargo update -p byteorder --precise 1.4.3
# Build MSRV with pinned versions.
cargo check --all-features --all-targets
fi
for dep in $DEPS
do

View File

@ -1,6 +1,7 @@
[package]
name = "bitcoin-fuzz"
edition = "2018"
edition = "2021"
rust-version = "1.56.1"
version = "0.0.1"
authors = ["Generated by fuzz/generate-files.sh"]
publish = false

View File

@ -11,7 +11,8 @@ source "$REPO_DIR/fuzz/fuzz-util.sh"
cat > "$REPO_DIR/fuzz/Cargo.toml" <<EOF
[package]
name = "bitcoin-fuzz"
edition = "2018"
edition = "2021"
rust-version = "1.56.1"
version = "0.0.1"
authors = ["Generated by fuzz/generate-files.sh"]
publish = false

View File

@ -9,7 +9,8 @@ description = "Hash functions used by the rust-bitcoin eccosystem"
categories = ["algorithms"]
keywords = [ "crypto", "bitcoin", "hash", "digest" ]
readme = "README.md"
edition = "2018"
edition = "2021"
rust-version = "1.56.1"
exclude = ["tests", "contrib"]
[features]

View File

@ -9,7 +9,7 @@ since these are needed to display hashes anway.
## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.48.0**.
This library should always compile with any combination of features on **Rust 1.56.1**.
To build with the MSRV you will need to pin `serde` (if you have either the `serde` or the

View File

@ -1,6 +1,6 @@
[package]
authors = ["Riccardo Casatta <riccardo@casatta.it>"]
edition = "2018"
edition = "2021"
readme = "README.md"
name = "embedded"
version = "0.1.0"

View File

@ -2,7 +2,7 @@
name = "schemars"
version = "0.1.0"
authors = ["Jeremy Rubin <j@rubin.io>"]
edition = "2018"
edition = "2021"
# Prevent this from interfering with workspaces
[workspace]

View File

@ -102,10 +102,10 @@ impl HashEngine {
for (i, &wi) in w.iter().enumerate() {
let (f, k) = match i {
0...19 => ((b & c) | (!b & d), 0x5a827999),
20...39 => (b ^ c ^ d, 0x6ed9eba1),
40...59 => ((b & c) | (b & d) | (c & d), 0x8f1bbcdc),
60...79 => (b ^ c ^ d, 0xca62c1d6),
0..=19 => ((b & c) | (!b & d), 0x5a827999),
20..=39 => (b ^ c ^ d, 0x6ed9eba1),
40..=59 => ((b & c) | (b & d) | (c & d), 0x8f1bbcdc),
60..=79 => (b ^ c ^ d, 0xca62c1d6),
_ => unreachable!(),
};

View File

@ -9,7 +9,8 @@ description = "Internal types and macros used by rust-bitcoin ecosystem"
categories = ["cryptography::cryptocurrencies"]
keywords = ["internal"]
readme = "README.md"
edition = "2018"
edition = "2021"
rust-version = "1.56.1"
exclude = ["tests", "contrib"]
[features]

View File

@ -1,4 +1,4 @@
const MSRV_MINOR: u64 = 48;
const MSRV_MINOR: u64 = 56;
fn main() {
let rustc = std::env::var_os("RUSTC");

View File

@ -47,7 +47,6 @@ mod impls {
})
}
#[cfg(rust_v_1_55)]
fn try_into_de_error<E>(self, expected: Option<&dyn de::Expected>) -> Result<E, Self>
where
E: de::Error,
@ -61,13 +60,5 @@ mod impls {
_ => Err(self),
}
}
#[cfg(not(rust_v_1_55))]
fn try_into_de_error<E>(self, _expected: Option<&dyn de::Expected>) -> Result<E, Self>
where
E: de::Error,
{
Err(self)
}
}
}

View File

@ -57,7 +57,7 @@ trailing_comma = "Vertical"
match_block_trailing_comma = false
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2018"
edition = "2021"
version = "One"
inline_attribute_width = 0
format_generated_files = true