Skip to content

Commit a90d4a6

Browse files
authored
Merge pull request #310 from cuviper/msrv-1.60
Use namespaced-features to safely bump to MSRV 1.60
2 parents eb20b40 + ca42b4e commit a90d4a6

File tree

14 files changed

+23
-273
lines changed

14 files changed

+23
-273
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
rust: [
12-
1.31.0, # MSRV
13-
1.35.0, # has_copysign
14-
1.37.0, # has_reverse_bits
15-
1.38.0, # has_div_euclid
16-
1.44.0, # has_to_int_unchecked
17-
1.46.0, # has_leading_trailing_ones
18-
1.53.0, # has_is_subnormal
12+
1.60.0, # MSRV
1913
1.62.0, # has_total_cmp
2014
stable,
2115
beta,

.github/workflows/master.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
rust: [1.31.0, stable]
16+
rust: [1.60.0, stable]
1717
steps:
1818
- uses: actions/checkout@v4
1919
- uses: actions/cache@v4

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
rust: [1.31.0, stable]
12+
rust: [1.60.0, stable]
1313
steps:
1414
- uses: actions/checkout@v4
1515
- uses: actions/cache@v4

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ version = "0.2.18"
1212
readme = "README.md"
1313
build = "build.rs"
1414
exclude = ["/ci/*", "/.github/*"]
15-
edition = "2018"
16-
rust-version = "1.31"
15+
edition = "2021"
16+
rust-version = "1.60"
1717

1818
[package.metadata.docs.rs]
1919
features = ["std"]
@@ -24,6 +24,7 @@ libm = { version = "0.2.0", optional = true }
2424

2525
[features]
2626
default = ["std"]
27+
libm = ["dep:libm"]
2728
std = []
2829

2930
# vestigial features, now always in effect

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![crate](https://img.shields.io/crates/v/num-traits.svg)](https://crates.io/crates/num-traits)
44
[![documentation](https://docs.rs/num-traits/badge.svg)](https://docs.rs/num-traits)
5-
[![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)
5+
[![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)
66
[![build status](https://github.com/rust-num/num-traits/workflows/master/badge.svg)](https://github.com/rust-num/num-traits/actions)
77

88
Numeric traits for generic mathematics in Rust.
@@ -40,7 +40,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
4040

4141
## Compatibility
4242

43-
The `num-traits` crate is tested for rustc 1.31 and greater.
43+
The `num-traits` crate is tested for rustc 1.60 and greater.
4444

4545
## License
4646

build.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
use std::env;
2-
31
fn main() {
42
let ac = autocfg::new();
53

6-
ac.emit_expression_cfg(
7-
"unsafe { 1f64.to_int_unchecked::<i32>() }",
8-
"has_to_int_unchecked",
9-
);
10-
11-
ac.emit_expression_cfg("1u32.reverse_bits()", "has_reverse_bits");
12-
ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones");
13-
ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid");
14-
15-
if env::var_os("CARGO_FEATURE_STD").is_some() {
16-
ac.emit_expression_cfg("1f64.copysign(-1f64)", "has_copysign");
17-
}
18-
ac.emit_expression_cfg("1f64.is_subnormal()", "has_is_subnormal");
19-
ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp");
20-
21-
ac.emit_expression_cfg("1u32.to_ne_bytes()", "has_int_to_from_bytes");
22-
ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes");
4+
ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62
235

246
autocfg::rerun_path("build.rs");
257
}

ci/rustup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
set -ex
66

77
ci=$(dirname $0)
8-
for version in 1.31.0 1.35.0 1.37.0 1.38.0 1.44.0 1.46.0 1.53.0 1.62.0 stable beta nightly; do
8+
for version in 1.60.0 1.62.0 stable beta nightly; do
99
rustup run "$version" "$ci/test_full.sh"
1010
done

ci/test_full.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
CRATE=num-traits
6-
MSRV=1.31
6+
MSRV=1.60
77

88
get_rust_version() {
99
local array=($(rustc --version));
@@ -32,9 +32,6 @@ echo "Testing supported features: ${FEATURES[*]}"
3232

3333
cargo generate-lockfile
3434

35-
# libm 0.2.6 started using {float}::EPSILON
36-
check_version 1.43 || cargo update -p libm --precise 0.2.5
37-
3835
set -x
3936

4037
# test the default

src/cast.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ macro_rules! impl_to_primitive_float_to_float {
277277
)*}
278278
}
279279

280-
#[cfg(has_to_int_unchecked)]
281280
macro_rules! float_to_int_unchecked {
282281
// SAFETY: Must not be NaN or infinite; must be representable as the integer after truncating.
283282
// We already checked that the float is in the exclusive range `(MIN-1, MAX+1)`.
@@ -286,13 +285,6 @@ macro_rules! float_to_int_unchecked {
286285
};
287286
}
288287

289-
#[cfg(not(has_to_int_unchecked))]
290-
macro_rules! float_to_int_unchecked {
291-
($float:expr => $int:ty) => {
292-
$float as $int
293-
};
294-
}
295-
296288
macro_rules! impl_to_primitive_float_to_signed_int {
297289
($f:ident : $( $(#[$cfg:meta])* fn $method:ident -> $i:ident ; )*) => {$(
298290
#[inline]

src/float.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ impl FloatCore for f32 {
790790
Self::is_infinite(self) -> bool;
791791
Self::is_finite(self) -> bool;
792792
Self::is_normal(self) -> bool;
793+
Self::is_subnormal(self) -> bool;
793794
Self::classify(self) -> FpCategory;
794795
Self::is_sign_positive(self) -> bool;
795796
Self::is_sign_negative(self) -> bool;
@@ -800,11 +801,6 @@ impl FloatCore for f32 {
800801
Self::to_radians(self) -> Self;
801802
}
802803

803-
#[cfg(has_is_subnormal)]
804-
forward! {
805-
Self::is_subnormal(self) -> bool;
806-
}
807-
808804
#[cfg(feature = "std")]
809805
forward! {
810806
Self::floor(self) -> Self;
@@ -855,6 +851,7 @@ impl FloatCore for f64 {
855851
Self::is_infinite(self) -> bool;
856852
Self::is_finite(self) -> bool;
857853
Self::is_normal(self) -> bool;
854+
Self::is_subnormal(self) -> bool;
858855
Self::classify(self) -> FpCategory;
859856
Self::is_sign_positive(self) -> bool;
860857
Self::is_sign_negative(self) -> bool;
@@ -865,11 +862,6 @@ impl FloatCore for f64 {
865862
Self::to_radians(self) -> Self;
866863
}
867864

868-
#[cfg(has_is_subnormal)]
869-
forward! {
870-
Self::is_subnormal(self) -> bool;
871-
}
872-
873865
#[cfg(feature = "std")]
874866
forward! {
875867
Self::floor(self) -> Self;
@@ -1901,6 +1893,7 @@ macro_rules! float_impl_std {
19011893
Self::is_infinite(self) -> bool;
19021894
Self::is_finite(self) -> bool;
19031895
Self::is_normal(self) -> bool;
1896+
Self::is_subnormal(self) -> bool;
19041897
Self::classify(self) -> FpCategory;
19051898
Self::floor(self) -> Self;
19061899
Self::ceil(self) -> Self;
@@ -1944,17 +1937,8 @@ macro_rules! float_impl_std {
19441937
Self::asinh(self) -> Self;
19451938
Self::acosh(self) -> Self;
19461939
Self::atanh(self) -> Self;
1947-
}
1948-
1949-
#[cfg(has_copysign)]
1950-
forward! {
19511940
Self::copysign(self, sign: Self) -> Self;
19521941
}
1953-
1954-
#[cfg(has_is_subnormal)]
1955-
forward! {
1956-
Self::is_subnormal(self) -> bool;
1957-
}
19581942
}
19591943
};
19601944
}
@@ -1993,6 +1977,7 @@ macro_rules! float_impl_libm {
19931977
Self::is_infinite(self) -> bool;
19941978
Self::is_finite(self) -> bool;
19951979
Self::is_normal(self) -> bool;
1980+
Self::is_subnormal(self) -> bool;
19961981
Self::classify(self) -> FpCategory;
19971982
Self::is_sign_positive(self) -> bool;
19981983
Self::is_sign_negative(self) -> bool;
@@ -2003,11 +1988,6 @@ macro_rules! float_impl_libm {
20031988
Self::to_radians(self) -> Self;
20041989
}
20051990

2006-
#[cfg(has_is_subnormal)]
2007-
forward! {
2008-
Self::is_subnormal(self) -> bool;
2009-
}
2010-
20111991
forward! {
20121992
FloatCore::signum(self) -> Self;
20131993
FloatCore::powi(self, n: i32) -> Self;

0 commit comments

Comments
 (0)