From ee87aebc7912d3e439fa059362952f2517c7bae7 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 13 Sep 2024 12:33:18 -0700 Subject: [PATCH] Update MSRV to 1.75 --- .github/workflows/build_and_test.yml | 2 +- rust/protocol/src/sealed_sender.rs | 5 +--- rust/protocol/src/utils.rs | 45 ---------------------------- rust/svr3/src/lib.rs | 6 ++-- 4 files changed, 4 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2b83943a..d3a8fe24 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,7 +9,7 @@ env: CARGO_TERM_COLOR: always NDK_VERSION: 27.0.12077973 RUST_BACKTRACE: 1 - LIBSIGNAL_MINIMUM_SUPPORTED_RUST_VERSION: 1.72 + LIBSIGNAL_MINIMUM_SUPPORTED_RUST_VERSION: 1.75 # For dev builds, include limited debug info in the output. See # https://doc.rust-lang.org/cargo/reference/profiles.html#debug CARGO_PROFILE_DEV_DEBUG: limited diff --git a/rust/protocol/src/sealed_sender.rs b/rust/protocol/src/sealed_sender.rs index 2cba494f..f6b97ff5 100644 --- a/rust/protocol/src/sealed_sender.rs +++ b/rust/protocol/src/sealed_sender.rs @@ -1451,10 +1451,7 @@ where let parallelism = std::thread::available_parallelism() .map(usize::from) .unwrap_or(1); - let chunk_size = std::cmp::max( - 6, - crate::utils::div_ceil(identity_keys_and_ranges.len(), parallelism), - ); + let chunk_size = std::cmp::max(6, identity_keys_and_ranges.len().div_ceil(parallelism)); if parallelism == 1 || chunk_size >= identity_keys_and_ranges.len() { process_chunk(&mut serialized, &identity_keys_and_ranges)?; diff --git a/rust/protocol/src/utils.rs b/rust/protocol/src/utils.rs index 62bbfeb2..67a108c8 100644 --- a/rust/protocol/src/utils.rs +++ b/rust/protocol/src/utils.rs @@ -4,7 +4,6 @@ // use std::cmp::Ordering; -use std::ops::{Add, Div, Rem}; fn expand_top_bit(a: u8) -> u8 { //if (a >> 7) == 1 { 0xFF } else { 0 } @@ -82,24 +81,6 @@ pub(crate) fn constant_time_cmp(x: &[u8], y: &[u8]) -> Ordering { } } -// To be replaced by 1.73's div_ceil when we update our MSRV. -#[inline] -pub(crate) fn div_ceil< - T: Copy + Div + Rem + Add + Ord + From, ->( - dividend: T, - divisor: T, -) -> T { - // From the std implementation of div_ceil. - let q = dividend / divisor; - let r = dividend % divisor; - if (r > 0u8.into() && divisor > 0u8.into()) || (r < 0u8.into() && divisor < 0u8.into()) { - q + 1u8.into() - } else { - q - } -} - #[cfg(test)] mod tests { use super::*; @@ -157,30 +138,4 @@ mod tests { } } } - - #[test] - fn test_div_ceil() { - assert_eq!(div_ceil(0_usize, 4), 0); - assert_eq!(div_ceil(7_usize, 4), 2); - assert_eq!(div_ceil(8_usize, 4), 2); - assert_eq!(div_ceil(9_usize, 4), 3); - } - - #[test] - #[should_panic] - fn test_div_ceil_panic() { - _ = div_ceil(4_usize, 0); - } - - // From https://doc.rust-lang.org/std/primitive.isize.html#method.div_ceil - #[test] - fn test_div_ceil_isize() { - let a: isize = 8; - let b = 3; - - assert_eq!(div_ceil(a, b), 3); - assert_eq!(div_ceil(a, -b), -2); - assert_eq!(div_ceil(-a, b), -2); - assert_eq!(div_ceil(-a, -b), 3); - } } diff --git a/rust/svr3/src/lib.rs b/rust/svr3/src/lib.rs index 1e5d3151..12e36a08 100644 --- a/rust/svr3/src/lib.rs +++ b/rust/svr3/src/lib.rs @@ -52,8 +52,7 @@ fn arr_xor(from: &[u8], into: &mut [u8]) { pub struct Query4 {} impl Query4 { - // Using `impl Iterator<...>` makes libsignal-net fail to build in Rust 1.72 - pub fn requests() -> std::iter::Repeat> { + pub fn requests() -> impl Iterator> { std::iter::repeat( svr4::Request4 { inner: Some(svr4::request4::Inner::Query(svr4::request4::Query {})), @@ -85,8 +84,7 @@ impl Query4 { pub struct Remove4 {} impl Remove4 { - // Using `impl Iterator<...>` makes libsignal-net fail to build in Rust 1.72 - pub fn requests() -> std::iter::Repeat> { + pub fn requests() -> impl Iterator> { std::iter::repeat( svr4::Request4 { inner: Some(svr4::request4::Inner::Remove(svr4::request4::Remove {})),