Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump MSRV to 1.79 #712

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
"stable",
"beta",
"nightly",
"1.65", # MSRV
"1.79", # MSRV
]
flags: [
# No features
Expand All @@ -36,10 +36,10 @@ jobs:
include:
# MSRV features
- os: "ubuntu-latest"
rust: "1.65" # MSRV
rust: "1.79" # MSRV
flags: "--features json"
- os: "windows-latest"
rust: "1.65" # MSRV
rust: "1.79" # MSRV
flags: "--features json"
# All features
- os: "ubuntu-latest"
Expand All @@ -61,10 +61,10 @@ jobs:
cache-on-failure: true
# Only run tests on latest stable and above
- name: build
if: ${{ matrix.rust == '1.65' }} # MSRV
if: ${{ matrix.rust == '1.79' }} # MSRV
run: cargo build --workspace ${{ matrix.flags }}
- name: test
if: ${{ matrix.rust != '1.65' }} # MSRV
if: ${{ matrix.rust != '1.79' }} # MSRV
run: cargo test --workspace ${{ matrix.flags }}

miri:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolver = "2"
[workspace.package]
version = "0.8.0"
edition = "2021"
rust-version = "1.65"
rust-version = "1.79"
authors = ["Alloy Contributors"]
license = "MIT OR Apache-2.0"
homepage = "https://github.com/alloy-rs/core"
Expand Down Expand Up @@ -61,7 +61,7 @@ quote = "1.0"
syn = "2.0"

cfg-if = "1.0.0"
derive_more = "0.99"
derive_more = { version = "1.0", features = ["full"] }
hex-literal = "0.4"
paste = "1.0"
num_enum = "0.7"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ When updating this, also update:
- .github/workflows/ci.yml
-->

The current MSRV (minimum supported rust version) is 1.65.
The current MSRV (minimum supported rust version) is 1.79.

Alloy will keep a rolling MSRV policy of **at least** two versions behind the
latest stable release (so if the latest stable release is 1.58, we would
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.65"
msrv = "1.79"
4 changes: 2 additions & 2 deletions crates/json-abi/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ macro_rules! iter_impl {
///
/// This `struct` is created by [`JsonAbi::items`]. See its documentation for
/// more.
#[derive(Clone, Debug)] // TODO(MSRV-1.70): derive Default
#[derive(Clone, Debug, Default)]
pub struct Items<'a> {
len: usize,
constructor: Option<&'a Constructor>,
Expand All @@ -428,7 +428,7 @@ iter_impl!(traits Items<'_>);
///
/// This `struct` is created by [`JsonAbi::into_items`]. See its documentation
/// for more.
#[derive(Debug)] // TODO(MSRV-1.70): derive Default
#[derive(Debug, Default)]
pub struct IntoItems {
len: usize,
constructor: Option<Constructor>,
Expand Down
11 changes: 1 addition & 10 deletions crates/primitives/src/bits/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub const BLOOM_SIZE_BITS: usize = BLOOM_SIZE_BYTES * 8;
/// Mask, used in accrue
const MASK: usize = BLOOM_SIZE_BITS - 1;
/// Number of bytes per item, used in accrue
// TODO(MSRV-1.67): use `usize::ilog2()`
const ITEM_BYTES: usize = (log2(BLOOM_SIZE_BITS) + 7) / 8;
const ITEM_BYTES: usize = (BLOOM_SIZE_BITS.ilog2() as usize + 7) / 8;

// BLOOM_SIZE_BYTES must be a power of 2
#[allow(clippy::assertions_on_constants)]
Expand Down Expand Up @@ -220,14 +219,6 @@ impl Bloom {
}
}

const fn log2(x: usize) -> usize {
if x <= 1 {
return 0;
}

(usize::BITS - x.leading_zeros()) as usize
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
7 changes: 3 additions & 4 deletions crates/primitives/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use bytes::{BufMut, BytesMut};
use derive_more::{Display, Error};
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type, WrongType};
use std::{
error::Error,
iter,
str::{from_utf8, FromStr},
};
Expand Down Expand Up @@ -59,7 +58,7 @@ fn trim_end_vec<T: PartialEq>(vec: &mut Vec<T>, value: &T) {
#[derive(Clone, Debug, PartialEq, Eq, Display, Error)]
pub enum ToSqlError {
/// The value is too large for the type.
#[display(fmt = "Signed<{_0}> value too large to fit target type {_1}")]
#[display("Signed<{_0}> value too large to fit target type {_1}")]
Overflow(usize, Type),
}

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

/// The value is not valid for the type.
#[display(fmt = "unexpected data for type {_0}")]
#[display("unexpected data for type {_0}")]
ParseError(Type),
}

Expand Down
16 changes: 4 additions & 12 deletions crates/sol-macro-expander/src/expand/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
\n\
See the [module-level documentation](self) for all the available methods."
);
let (deploy_fn, deploy_method) = option_unzip(bytecode.is_some().then(|| {
let (deploy_fn, deploy_method) = bytecode.is_some().then(|| {
let deploy_doc_str =
"Deploys this contract using the given `provider` and constructor arguments, if any.\n\
\n\
Expand All @@ -292,7 +292,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
the bytecode concatenated with the constructor's ABI-encoded arguments.";
let deploy_builder_doc = mk_doc(deploy_builder_doc_str);

let (params, args) = option_unzip(constructor.and_then(|c| {
let (params, args) = constructor.and_then(|c| {
if c.parameters.is_empty() {
return None;
}
Expand All @@ -303,7 +303,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
super::ty::expand_rust_type(ty, &cx.crates)
});
Some((quote!(#(#names1: #tys),*), quote!(#(#names2,)*)))
}));
}).unzip();
let deploy_builder_data = if matches!(constructor, Some(c) if !c.parameters.is_empty()) {
quote! {
[
Expand Down Expand Up @@ -355,7 +355,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result<To
}
},
)
}));
}).unzip();

let filter_methods = events.iter().map(|&e| {
let event_name = cx.overloaded_name(e.into());
Expand Down Expand Up @@ -1014,11 +1014,3 @@ fn snakify(s: &str) -> String {
}
output.into_iter().collect()
}

// TODO(MSRV-1.66): Option::unzip
fn option_unzip<T, U>(opt: Option<(T, U)>) -> (Option<T>, Option<U>) {
match opt {
Some((a, b)) => (Some(a), Some(b)),
None => (None, None),
}
}
14 changes: 8 additions & 6 deletions crates/sol-types/src/abi/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,14 @@ pub fn decode<'de, T: Token<'de>>(data: &'de [u8], validate: bool) -> Result<T>
/// See the [`abi`](super) module for more information.
#[inline(always)]
pub fn decode_params<'de, T: TokenSeq<'de>>(data: &'de [u8], validate: bool) -> Result<T> {
// TODO(MSRV-1.79): Use `const {}` to select the function at compile time.
if T::IS_TUPLE {
decode_sequence(data, validate)
} else {
decode(data, validate)
}
let decode = const {
if T::IS_TUPLE {
decode_sequence
} else {
decode
}
};
decode(data, validate)
}

/// Decodes ABI compliant vector of bytes into vector of tokens described by
Expand Down
14 changes: 8 additions & 6 deletions crates/sol-types/src/abi/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ pub fn encode<'a, T: Token<'a>>(token: &T) -> Vec<u8> {
/// See the [`abi`](super) module for more information.
#[inline(always)]
pub fn encode_params<'a, T: TokenSeq<'a>>(token: &T) -> Vec<u8> {
// TODO(MSRV-1.79): Use `const {}` to select the function at compile time.
if T::IS_TUPLE {
encode_sequence(token)
} else {
encode(token)
}
let encode = const {
if T::IS_TUPLE {
encode_sequence
} else {
encode
}
};
encode(token)
}

/// ABI-encodes a token sequence.
Expand Down
14 changes: 0 additions & 14 deletions crates/sol-types/src/types/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,24 +1156,10 @@ impl NameBuffer {
}

const fn write_usize(mut self, number: usize) -> Self {
if number == 0 {
return self.write_byte(b'0');
}

let mut n = number;
let mut digits = 0;
while n > 0 {
n /= 10;
digits += 1;
}

// TODO(MSRV-1.67): Uncomment and remove everything above
/*
let Some(digits) = number.checked_ilog10() else {
return self.write_byte(b'0');
};
let digits = digits as usize + 1;
*/

let mut n = number;
let mut i = self.len + digits;
Expand Down
44 changes: 22 additions & 22 deletions crates/sol-types/tests/macros/sol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,70 +720,70 @@ fn duplicate_events() {
sol! {
#[derive(derive_more::Display)]
interface Console {
#[display(fmt = "{val}")]
#[display("{val}")]
event log(string val);

#[display(fmt = "{}", "hex::encode_prefixed(val)")]
#[display("{}", "hex::encode_prefixed(val)")]
event logs(bytes val);

#[display(fmt = "{val}")]
#[display("{val}")]
event log_address(address val);

#[display(fmt = "{val}")]
#[display("{val}")]
event log_bytes32(bytes32 val);

#[display(fmt = "{val}")]
#[display("{val}")]
event log_int(int val);

#[display(fmt = "{val}")]
#[display("{val}")]
event log_uint(uint val);

#[display(fmt = "{}", "hex::encode_prefixed(val)")]
#[display("{}", "hex::encode_prefixed(val)")]
event log_bytes(bytes val);

#[display(fmt = "{val}")]
#[display("{val}")]
event log_string(string val);

#[display(fmt = "{val:?}")]
#[display("{val:?}")]
event log_array(uint256[] val);

#[display(fmt = "{val:?}")]
#[display("{val:?}")]
event log_array(int256[] val);

#[display(fmt = "{val:?}")]
#[display("{val:?}")]
event log_array(address[] val);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_address(string key, address val);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_bytes32(string key, bytes32 val);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_decimal_int(string key, int val, uint decimals);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_decimal_uint(string key, uint val, uint decimals);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_int(string key, int val);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_uint(string key, uint val);

#[display(fmt = "{key}: {val:?}")]
#[display("{key}: {val:?}")]
event log_named_bytes(string key, bytes val);

#[display(fmt = "{key}: {val}")]
#[display("{key}: {val}")]
event log_named_string(string key, string val);

#[display(fmt = "{key}: {val:?}")]
#[display("{key}: {val:?}")]
event log_named_array(string key, uint256[] val);

#[display(fmt = "{key}: {val:?}")]
#[display("{key}: {val:?}")]
event log_named_array(string key, int256[] val);

#[display(fmt = "{key}: {val:?}")]
#[display("{key}: {val:?}")]
event log_named_array(string key, address[] val);
}
}
Expand Down