Skip to content

Commit d8061b8

Browse files
committed
Merge #269: bump MSRV to 1.74.0
a735854 clippy: use let...else syntax (Andrew Poelstra) 52d1cd1 clippy: use new div_ceil method (Andrew Poelstra) f9d7938 bump MSRV to 1.74.0 (Andrew Poelstra) Pull request description: This matches the rust-bitcoin ecosystem, and in particular bitcoin-consensus-encoding which we hope to replace our homebrew encoding traits with. This MSRV is also needed to use libfuzzer, which is used by cargo-fuzz. lwk and rust-simplicity both have higher MSRVs so there seems to be little point here in having a very old one. ACKs for top commit: apoelstra: ACK a735854; successfully ran local tests delta1: ACK a735854; tested locally Tree-SHA512: b8fa34a1b7c97c15f8f04332238d9746bb6c7a6a7e094d14fc52db4fa2ffb2ea1577b2906098b69669de8bcf02011bdb5d99afc0918f182834c277de0b9ae692
2 parents bf0456d + a735854 commit d8061b8

7 files changed

Lines changed: 14 additions & 19 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ homepage = "https://github.com/ElementsProject/rust-elements/"
88
repository = "https://github.com/ElementsProject/rust-elements/"
99
documentation = "https://docs.rs/elements/"
1010
edition = "2018"
11-
rust-version = "1.63.0"
11+
rust-version = "1.74.0"
1212

1313
[workspace.metadata.rbmt.toolchains]
1414
nightly = "nightly-2026-04-17"

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ structures and network messages related to Elements
77

88
[Documentation](https://docs.rs/elements/)
99

10-
1110
## Minimum Supported Rust Version (MSRV)
1211

13-
This library should always compile with any combination of features on **Rust 1.48.0**.
12+
This library should always compile with any combination of features on **Rust 1.74.0**.

elementsd-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "elementsd-tests"
33
version = "0.1.0"
44
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
55
edition = "2018"
6-
rust-version = "1.63.0"
6+
rust-version = "1.74.0"
77

88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

src/blind.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,8 @@ impl TxOut {
740740
secp: &Secp256k1<C>,
741741
blinding_key: SecretKey,
742742
) -> Result<TxOutSecrets, UnblindError> {
743-
let (commitment, additional_generator) = match (self.value, self.asset) {
744-
(Value::Confidential(com), Asset::Confidential(gen)) => (com, gen),
745-
_ => return Err(UnblindError::NotConfidential),
743+
let (Value::Confidential(commitment), Asset::Confidential(additional_generator)) = (self.value, self.asset) else {
744+
return Err(UnblindError::NotConfidential);
746745
};
747746

748747
let shared_secret = self

src/internal_macros.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ macro_rules! serde_struct_impl {
110110
}
111111

112112
$(
113-
let $fe = match $fe {
114-
Some(x) => x,
115-
None => return Err(A::Error::missing_field(stringify!($fe))),
113+
let Some($fe) = $fe else {
114+
return Err(A::Error::missing_field(stringify!($fe)));
116115
};
117116
)*
118117

@@ -348,9 +347,8 @@ macro_rules! serde_struct_human_string_impl {
348347
}
349348

350349
$(
351-
let $fe = match $fe {
352-
Some(x) => x,
353-
None => return Err(A::Error::missing_field(stringify!($fe))),
350+
let Some($fe) = $fe else {
351+
return Err(A::Error::missing_field(stringify!($fe)));
354352
};
355353
)*
356354

src/pset/serialize.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ impl Serialize for KeySource {
176176

177177
impl Deserialize for KeySource {
178178
fn deserialize(bytes: &[u8]) -> Result<Self, encode::Error> {
179-
let prefix = match <[u8; 4]>::try_from(&bytes[0..4]) {
180-
Ok(prefix) => prefix,
181-
Err(_) => return Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
179+
let Ok(prefix) = <[u8; 4]>::try_from(&bytes[0..4]) else {
180+
return Err(io::Error::from(io::ErrorKind::UnexpectedEof).into());
182181
};
183182

184183
let fprint: Fingerprint = Fingerprint::from(prefix);

src/transaction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl Sequence {
281281
/// Will return an error if the input cannot be encoded in 16 bits.
282282
#[inline]
283283
pub fn from_seconds_ceil(seconds: u32) -> Result<Self, RelativeLockTimeError> {
284-
if let Ok(interval) = u16::try_from((seconds + 511) / 512) {
284+
if let Ok(interval) = u16::try_from(seconds.div_ceil(512)) {
285285
Ok(Sequence::from_512_second_intervals(interval))
286286
} else {
287287
Err(RelativeLockTimeError::IntegerOverflow(seconds))
@@ -927,7 +927,7 @@ impl Transaction {
927927
#[inline]
928928
pub fn vsize(&self) -> usize {
929929
let weight = self.weight();
930-
(weight + 4 - 1) / 4
930+
weight.div_ceil(4)
931931
}
932932

933933
/// Get the "discount weight" of this transaction; this is the weight minus the output witnesses and minus the
@@ -955,7 +955,7 @@ impl Transaction {
955955
///
956956
/// Will be `ceil(discount weight / 4.0)`.
957957
pub fn discount_vsize(&self) -> usize {
958-
(self.discount_weight() + 4 - 1) / 4
958+
self.discount_weight().div_ceil(4)
959959
}
960960

961961
fn scaled_size(&self, scale_factor: usize) -> usize {

0 commit comments

Comments
 (0)