From 211a0ca57d2dde6ec0e4a9d9236c533cc3726b7d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 18:35:41 -0800 Subject: [PATCH 1/3] Use namespaced-features to safely bump to MSRV 1.60 Earlier versions won't see the incompatible updates at all! --- .github/workflows/ci.yaml | 4 +--- .github/workflows/master.yaml | 2 +- .github/workflows/pr.yaml | 2 +- Cargo.toml | 6 ++++++ README.md | 4 ++-- ci/rustup.sh | 2 +- ci/test_full.sh | 19 ++----------------- 7 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 779aeb4..9d875a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,9 +9,7 @@ jobs: strategy: matrix: rust: [ - 1.31.0, # 2018! - 1.36.0, # rand - 1.54.0, # rkyv + 1.60.0, # MSRV stable, beta, nightly diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index 68c4900..034e379 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [1.31.0, stable] + rust: [1.60.0, stable] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 787f908..baac648 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [1.31.0, stable] + rust: [1.60.0, stable] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/Cargo.toml b/Cargo.toml index c807548..61af2cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ version = "0.4.5" readme = "README.md" exclude = ["/ci/*", "/.github/*"] edition = "2018" +rust-version = "1.60" [package.metadata.docs.rs] features = ["bytemuck", "std", "serde", "rkyv/size_64", "bytecheck", "rand"] @@ -51,3 +52,8 @@ default-features = false default = ["std"] std = ["num-traits/std"] libm = ["num-traits/libm"] +bytecheck = ["dep:bytecheck"] +bytemuck = ["dep:bytemuck"] +rand = ["dep:rand"] +rkyv = ["dep:rkyv"] +serde = ["dep:serde"] diff --git a/README.md b/README.md index fdb1d38..6075cd6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![crate](https://img.shields.io/crates/v/num-complex.svg)](https://crates.io/crates/num-complex) [![documentation](https://docs.rs/num-complex/badge.svg)](https://docs.rs/num-complex) -[![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) +[![minimum rustc 1.60](https://img.shields.io/badge/rustc-1.60+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) [![build status](https://github.com/rust-num/num-complex/workflows/master/badge.svg)](https://github.com/rust-num/num-complex/actions) `Complex` numbers for Rust. @@ -37,7 +37,7 @@ Release notes are available in [RELEASES.md](RELEASES.md). ## Compatibility -The `num-complex` crate is tested for rustc 1.31 and greater. +The `num-complex` crate is tested for rustc 1.60 and greater. ## License diff --git a/ci/rustup.sh b/ci/rustup.sh index 1164e8a..6cfe67e 100755 --- a/ci/rustup.sh +++ b/ci/rustup.sh @@ -5,6 +5,6 @@ set -ex ci=$(dirname $0) -for version in 1.31.0 1.36.0 1.54.0 stable beta nightly; do +for version in 1.60.0 stable beta nightly; do rustup run "$version" "$ci/test_full.sh" done diff --git a/ci/test_full.sh b/ci/test_full.sh index 4b29bb7..84f8762 100755 --- a/ci/test_full.sh +++ b/ci/test_full.sh @@ -3,7 +3,7 @@ set -e CRATE=num-complex -MSRV=1.31 +MSRV=1.60 get_rust_version() { local array=($(rustc --version)); @@ -27,26 +27,11 @@ if ! check_version $MSRV ; then exit 1 fi -FEATURES=(libm serde) -check_version 1.34 && FEATURES+=(bytemuck) -check_version 1.36 && FEATURES+=(rand) -check_version 1.54 && FEATURES+=(rkyv/size_64 bytecheck) +FEATURES=(bytecheck bytemuck libm rand rkyv/size_64 serde) echo "Testing supported features: ${FEATURES[*]}" cargo generate-lockfile -# libm 0.2.6 started using {float}::EPSILON -check_version 1.43 || cargo update -p libm --precise 0.2.5 - -# Some crates moved to Rust 1.56 / 2021 -check_version 1.56 || ( - cargo update -p serde --precise 1.0.185 - cargo update -p quote --precise 1.0.30 - cargo update -p proc-macro2 --precise 1.0.65 - cargo update -p rkyv --precise 0.7.40 - cargo update -p bytecheck --precise 0.6.9 -) - set -x # test the default From 91b818c1d02cc17b8fe492934856d44407a8321c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 18:36:47 -0800 Subject: [PATCH 2/3] Upgrade to 2021 edition --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 61af2cc..050537b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/rust-num/num-complex" version = "0.4.5" readme = "README.md" exclude = ["/ci/*", "/.github/*"] -edition = "2018" +edition = "2021" rust-version = "1.60" [package.metadata.docs.rs] From 0c3f2efe31fdd594e9cd395c301d99b389a20d87 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 18:38:00 -0800 Subject: [PATCH 3/3] Fix clippy::collapsible_else_if --- src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 13a884b..3c647e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,13 +213,11 @@ impl Complex { if !im.is_finite() { return Self::new(T::zero(), T::zero()); } - } else { - if im == T::zero() || !im.is_finite() { - if im.is_infinite() { - im = T::nan(); - } - return Self::new(re, im); + } else if im == T::zero() || !im.is_finite() { + if im.is_infinite() { + im = T::nan(); } + return Self::new(re, im); } } else if re.is_nan() && im == T::zero() { return self;