From d9cc724187def13232602955650e922224880d97 Mon Sep 17 00:00:00 2001
From: "Tobin C. Harding"
Date: Tue, 14 Nov 2023 15:13:38 +1100
Subject: [PATCH] Bump MSRV to Rust version 1.56.1
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,
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
---
.github/workflows/rust.yml | 4 ++--
README.md | 4 ++--
bitcoin/CHANGELOG.md | 4 ++++
bitcoin/build.rs | 2 +-
bitcoin/src/blockdata/script/borrowed.rs | 11 +++++------
bitcoin/src/blockdata/script/push_bytes.rs | 9 +++------
bitcoin/src/taproot.rs | 2 +-
clippy.toml | 2 +-
contrib/test.sh | 16 ----------------
hashes/README.md | 2 +-
internals/build.rs | 2 +-
internals/src/serde.rs | 9 ---------
12 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index a59589ef..9ec28ce0 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -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
diff --git a/README.md b/README.md
index 33c869a6..c9d21cef 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
-
+
@@ -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.
diff --git a/bitcoin/CHANGELOG.md b/bitcoin/CHANGELOG.md
index ebc8f9fb..b5b1d624 100644
--- a/bitcoin/CHANGELOG.md
+++ b/bitcoin/CHANGELOG.md
@@ -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)
diff --git a/bitcoin/build.rs b/bitcoin/build.rs
index b5e2f5f6..15add3f3 100644
--- a/bitcoin/build.rs
+++ b/bitcoin/build.rs
@@ -1,4 +1,4 @@
-const MSRV_MINOR: u64 = 48;
+const MSRV_MINOR: u64 = 56;
fn main() {
let rustc = std::env::var_os("RUSTC");
diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs
index b9da4c56..117e34d0 100644
--- a/bitcoin/src/blockdata/script/borrowed.rs
+++ b/bitcoin/src/blockdata/script/borrowed.rs
@@ -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,
RangeFull,
RangeInclusive,
- RangeToInclusive
+ RangeToInclusive,
+ (Bound, Bound)
);
-#[cfg(rust_v_1_53)]
-delegate_index!((Bound, Bound));
diff --git a/bitcoin/src/blockdata/script/push_bytes.rs b/bitcoin/src/blockdata/script/push_bytes.rs
index 3baec542..6ca8a906 100644
--- a/bitcoin/src/blockdata/script/push_bytes.rs
+++ b/bitcoin/src/blockdata/script/push_bytes.rs
@@ -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,
RangeFull,
RangeInclusive,
- RangeToInclusive
+ RangeToInclusive,
+ (Bound, Bound)
);
- #[cfg(rust_v_1_53)]
- delegate_index!((Bound, Bound));
impl Index for PushBytes {
type Output = u8;
diff --git a/bitcoin/src/taproot.rs b/bitcoin/src/taproot.rs
index 8e4dab06..72ffab65 100644
--- a/bitcoin/src/taproot.rs
+++ b/bitcoin/src/taproot.rs
@@ -1845,7 +1845,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(
diff --git a/clippy.toml b/clippy.toml
index 6fbdb48f..173999bc 100644
--- a/clippy.toml
+++ b/clippy.toml
@@ -1,2 +1,2 @@
-msrv = "1.48.0"
+msrv = "1.56.1"
too-many-arguments-threshold = 13
diff --git a/contrib/test.sh b/contrib/test.sh
index 51abc82a..1e40fb1e 100755
--- a/contrib/test.sh
+++ b/contrib/test.sh
@@ -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
diff --git a/hashes/README.md b/hashes/README.md
index 809a173b..433a9593 100644
--- a/hashes/README.md
+++ b/hashes/README.md
@@ -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
diff --git a/internals/build.rs b/internals/build.rs
index b5e2f5f6..15add3f3 100644
--- a/internals/build.rs
+++ b/internals/build.rs
@@ -1,4 +1,4 @@
-const MSRV_MINOR: u64 = 48;
+const MSRV_MINOR: u64 = 56;
fn main() {
let rustc = std::env::var_os("RUSTC");
diff --git a/internals/src/serde.rs b/internals/src/serde.rs
index 14c5a49c..de79756a 100644
--- a/internals/src/serde.rs
+++ b/internals/src/serde.rs
@@ -47,7 +47,6 @@ mod impls {
})
}
- #[cfg(rust_v_1_55)]
fn try_into_de_error(self, expected: Option<&dyn de::Expected>) -> Result
where
E: de::Error,
@@ -61,13 +60,5 @@ mod impls {
_ => Err(self),
}
}
-
- #[cfg(not(rust_v_1_55))]
- fn try_into_de_error(self, _expected: Option<&dyn de::Expected>) -> Result
- where
- E: de::Error,
- {
- Err(self)
- }
}
}