diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d6a4eeb1..e95a98481 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: "stable", "beta", "nightly", - "1.65", # MSRV + "1.79", # MSRV ] flags: [ # No features @@ -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" @@ -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: diff --git a/Cargo.toml b/Cargo.toml index 3b95a2a92..0b6631bc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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" diff --git a/README.md b/README.md index 0a73212b2..da22c178d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/clippy.toml b/clippy.toml index 04371125d..f1acf4b11 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.65" +msrv = "1.79" diff --git a/crates/json-abi/src/abi.rs b/crates/json-abi/src/abi.rs index ffed8f1d2..54c7118e0 100644 --- a/crates/json-abi/src/abi.rs +++ b/crates/json-abi/src/abi.rs @@ -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>, @@ -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, diff --git a/crates/primitives/src/bits/bloom.rs b/crates/primitives/src/bits/bloom.rs index 117c180eb..e64683eda 100644 --- a/crates/primitives/src/bits/bloom.rs +++ b/crates/primitives/src/bits/bloom.rs @@ -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)] @@ -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::*; diff --git a/crates/primitives/src/postgres.rs b/crates/primitives/src/postgres.rs index 66d289766..8fa6b6a70 100644 --- a/crates/primitives/src/postgres.rs +++ b/crates/primitives/src/postgres.rs @@ -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}, }; @@ -59,7 +58,7 @@ fn trim_end_vec(vec: &mut Vec, 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), } @@ -214,11 +213,11 @@ impl ToSql for Signed { #[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), } diff --git a/crates/sol-macro-expander/src/expand/contract.rs b/crates/sol-macro-expander/src/expand/contract.rs index ffa1a15bc..e49f917b7 100644 --- a/crates/sol-macro-expander/src/expand/contract.rs +++ b/crates/sol-macro-expander/src/expand/contract.rs @@ -275,7 +275,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result, contract: &ItemContract) -> Result, contract: &ItemContract) -> Result String { } output.into_iter().collect() } - -// TODO(MSRV-1.66): Option::unzip -fn option_unzip(opt: Option<(T, U)>) -> (Option, Option) { - match opt { - Some((a, b)) => (Some(a), Some(b)), - None => (None, None), - } -} diff --git a/crates/sol-types/src/abi/decoder.rs b/crates/sol-types/src/abi/decoder.rs index d63e65321..bc7ceb608 100644 --- a/crates/sol-types/src/abi/decoder.rs +++ b/crates/sol-types/src/abi/decoder.rs @@ -300,12 +300,14 @@ pub fn decode<'de, T: Token<'de>>(data: &'de [u8], validate: bool) -> Result /// See the [`abi`](super) module for more information. #[inline(always)] pub fn decode_params<'de, T: TokenSeq<'de>>(data: &'de [u8], validate: bool) -> Result { - // 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 diff --git a/crates/sol-types/src/abi/encoder.rs b/crates/sol-types/src/abi/encoder.rs index 50852d3d3..23fd77d8d 100644 --- a/crates/sol-types/src/abi/encoder.rs +++ b/crates/sol-types/src/abi/encoder.rs @@ -185,12 +185,14 @@ pub fn encode<'a, T: Token<'a>>(token: &T) -> Vec { /// See the [`abi`](super) module for more information. #[inline(always)] pub fn encode_params<'a, T: TokenSeq<'a>>(token: &T) -> Vec { - // 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. diff --git a/crates/sol-types/src/types/data_type.rs b/crates/sol-types/src/types/data_type.rs index 30646d80e..48fd682da 100644 --- a/crates/sol-types/src/types/data_type.rs +++ b/crates/sol-types/src/types/data_type.rs @@ -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; diff --git a/crates/sol-types/tests/macros/sol/mod.rs b/crates/sol-types/tests/macros/sol/mod.rs index ccecedb0d..4300bcad3 100644 --- a/crates/sol-types/tests/macros/sol/mod.rs +++ b/crates/sol-types/tests/macros/sol/mod.rs @@ -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); } }