Skip to content

Commit 1ebee07

Browse files
authored
chore: bump MSRV to 1.79 (#712)
1 parent 4bc727d commit 1ebee07

File tree

12 files changed

+57
-85
lines changed

12 files changed

+57
-85
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
"stable",
2626
"beta",
2727
"nightly",
28-
"1.65", # MSRV
28+
"1.79", # MSRV
2929
]
3030
flags: [
3131
# No features
@@ -36,10 +36,10 @@ jobs:
3636
include:
3737
# MSRV features
3838
- os: "ubuntu-latest"
39-
rust: "1.65" # MSRV
39+
rust: "1.79" # MSRV
4040
flags: "--features json"
4141
- os: "windows-latest"
42-
rust: "1.65" # MSRV
42+
rust: "1.79" # MSRV
4343
flags: "--features json"
4444
# All features
4545
- os: "ubuntu-latest"
@@ -61,10 +61,10 @@ jobs:
6161
cache-on-failure: true
6262
# Only run tests on latest stable and above
6363
- name: build
64-
if: ${{ matrix.rust == '1.65' }} # MSRV
64+
if: ${{ matrix.rust == '1.79' }} # MSRV
6565
run: cargo build --workspace ${{ matrix.flags }}
6666
- name: test
67-
if: ${{ matrix.rust != '1.65' }} # MSRV
67+
if: ${{ matrix.rust != '1.79' }} # MSRV
6868
run: cargo test --workspace ${{ matrix.flags }}
6969

7070
miri:

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.package]
66
version = "0.8.0"
77
edition = "2021"
8-
rust-version = "1.65"
8+
rust-version = "1.79"
99
authors = ["Alloy Contributors"]
1010
license = "MIT OR Apache-2.0"
1111
homepage = "https://github.com/alloy-rs/core"
@@ -61,7 +61,7 @@ quote = "1.0"
6161
syn = "2.0"
6262

6363
cfg-if = "1.0.0"
64-
derive_more = "0.99"
64+
derive_more = { version = "1.0", features = ["full"] }
6565
hex-literal = "0.4"
6666
paste = "1.0"
6767
num_enum = "0.7"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ When updating this, also update:
5656
- .github/workflows/ci.yml
5757
-->
5858

59-
The current MSRV (minimum supported rust version) is 1.65.
59+
The current MSRV (minimum supported rust version) is 1.79.
6060

6161
Alloy will keep a rolling MSRV policy of **at least** two versions behind the
6262
latest stable release (so if the latest stable release is 1.58, we would

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.65"
1+
msrv = "1.79"

crates/json-abi/src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ macro_rules! iter_impl {
405405
///
406406
/// This `struct` is created by [`JsonAbi::items`]. See its documentation for
407407
/// more.
408-
#[derive(Clone, Debug)] // TODO(MSRV-1.70): derive Default
408+
#[derive(Clone, Debug, Default)]
409409
pub struct Items<'a> {
410410
len: usize,
411411
constructor: Option<&'a Constructor>,
@@ -428,7 +428,7 @@ iter_impl!(traits Items<'_>);
428428
///
429429
/// This `struct` is created by [`JsonAbi::into_items`]. See its documentation
430430
/// for more.
431-
#[derive(Debug)] // TODO(MSRV-1.70): derive Default
431+
#[derive(Debug, Default)]
432432
pub struct IntoItems {
433433
len: usize,
434434
constructor: Option<Constructor>,

crates/primitives/src/bits/bloom.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ pub const BLOOM_SIZE_BITS: usize = BLOOM_SIZE_BYTES * 8;
1414
/// Mask, used in accrue
1515
const MASK: usize = BLOOM_SIZE_BITS - 1;
1616
/// Number of bytes per item, used in accrue
17-
// TODO(MSRV-1.67): use `usize::ilog2()`
18-
const ITEM_BYTES: usize = (log2(BLOOM_SIZE_BITS) + 7) / 8;
17+
const ITEM_BYTES: usize = (BLOOM_SIZE_BITS.ilog2() as usize + 7) / 8;
1918

2019
// BLOOM_SIZE_BYTES must be a power of 2
2120
#[allow(clippy::assertions_on_constants)]
@@ -220,14 +219,6 @@ impl Bloom {
220219
}
221220
}
222221

223-
const fn log2(x: usize) -> usize {
224-
if x <= 1 {
225-
return 0;
226-
}
227-
228-
(usize::BITS - x.leading_zeros()) as usize
229-
}
230-
231222
#[cfg(test)]
232223
mod tests {
233224
use super::*;

crates/primitives/src/postgres.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use bytes::{BufMut, BytesMut};
88
use derive_more::{Display, Error};
99
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type, WrongType};
1010
use std::{
11-
error::Error,
1211
iter,
1312
str::{from_utf8, FromStr},
1413
};
@@ -59,7 +58,7 @@ fn trim_end_vec<T: PartialEq>(vec: &mut Vec<T>, value: &T) {
5958
#[derive(Clone, Debug, PartialEq, Eq, Display, Error)]
6059
pub enum ToSqlError {
6160
/// The value is too large for the type.
62-
#[display(fmt = "Signed<{_0}> value too large to fit target type {_1}")]
61+
#[display("Signed<{_0}> value too large to fit target type {_1}")]
6362
Overflow(usize, Type),
6463
}
6564

@@ -214,11 +213,11 @@ impl<const BITS: usize, const LIMBS: usize> ToSql for Signed<BITS, LIMBS> {
214213
#[derive(Clone, Debug, PartialEq, Eq, Display)]
215214
pub enum FromSqlError {
216215
/// The value is too large for the type.
217-
#[display(fmt = "The value is too large for the Signed type")]
216+
#[display("the value is too large for the Signed type")]
218217
Overflow,
219218

220219
/// The value is not valid for the type.
221-
#[display(fmt = "unexpected data for type {_0}")]
220+
#[display("unexpected data for type {_0}")]
222221
ParseError(Type),
223222
}
224223

crates/sol-macro-expander/src/expand/contract.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
275275
\n\
276276
See the [module-level documentation](self) for all the available methods."
277277
);
278-
let (deploy_fn, deploy_method) = option_unzip(bytecode.is_some().then(|| {
278+
let (deploy_fn, deploy_method) = bytecode.is_some().then(|| {
279279
let deploy_doc_str =
280280
"Deploys this contract using the given `provider` and constructor arguments, if any.\n\
281281
\n\
@@ -292,7 +292,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
292292
the bytecode concatenated with the constructor's ABI-encoded arguments.";
293293
let deploy_builder_doc = mk_doc(deploy_builder_doc_str);
294294

295-
let (params, args) = option_unzip(constructor.and_then(|c| {
295+
let (params, args) = constructor.and_then(|c| {
296296
if c.parameters.is_empty() {
297297
return None;
298298
}
@@ -303,7 +303,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
303303
super::ty::expand_rust_type(ty, &cx.crates)
304304
});
305305
Some((quote!(#(#names1: #tys),*), quote!(#(#names2,)*)))
306-
}));
306+
}).unzip();
307307
let deploy_builder_data = if matches!(constructor, Some(c) if !c.parameters.is_empty()) {
308308
quote! {
309309
[
@@ -355,7 +355,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
355355
}
356356
},
357357
)
358-
}));
358+
}).unzip();
359359

360360
let filter_methods = events.iter().map(|&e| {
361361
let event_name = cx.overloaded_name(e.into());
@@ -1014,11 +1014,3 @@ fn snakify(s: &str) -> String {
10141014
}
10151015
output.into_iter().collect()
10161016
}
1017-
1018-
// TODO(MSRV-1.66): Option::unzip
1019-
fn option_unzip<T, U>(opt: Option<(T, U)>) -> (Option<T>, Option<U>) {
1020-
match opt {
1021-
Some((a, b)) => (Some(a), Some(b)),
1022-
None => (None, None),
1023-
}
1024-
}

crates/sol-types/src/abi/decoder.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,14 @@ pub fn decode<'de, T: Token<'de>>(data: &'de [u8], validate: bool) -> Result<T>
300300
/// See the [`abi`](super) module for more information.
301301
#[inline(always)]
302302
pub fn decode_params<'de, T: TokenSeq<'de>>(data: &'de [u8], validate: bool) -> Result<T> {
303-
// TODO(MSRV-1.79): Use `const {}` to select the function at compile time.
304-
if T::IS_TUPLE {
305-
decode_sequence(data, validate)
306-
} else {
307-
decode(data, validate)
308-
}
303+
let decode = const {
304+
if T::IS_TUPLE {
305+
decode_sequence
306+
} else {
307+
decode
308+
}
309+
};
310+
decode(data, validate)
309311
}
310312

311313
/// Decodes ABI compliant vector of bytes into vector of tokens described by

crates/sol-types/src/abi/encoder.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ pub fn encode<'a, T: Token<'a>>(token: &T) -> Vec<u8> {
185185
/// See the [`abi`](super) module for more information.
186186
#[inline(always)]
187187
pub fn encode_params<'a, T: TokenSeq<'a>>(token: &T) -> Vec<u8> {
188-
// TODO(MSRV-1.79): Use `const {}` to select the function at compile time.
189-
if T::IS_TUPLE {
190-
encode_sequence(token)
191-
} else {
192-
encode(token)
193-
}
188+
let encode = const {
189+
if T::IS_TUPLE {
190+
encode_sequence
191+
} else {
192+
encode
193+
}
194+
};
195+
encode(token)
194196
}
195197

196198
/// ABI-encodes a token sequence.

0 commit comments

Comments
 (0)