Skip to content

Commit cf1c7ed

Browse files
committed
Use assoc float consts in libcore
1 parent 65e10e3 commit cf1c7ed

File tree

8 files changed

+18
-28
lines changed

8 files changed

+18
-28
lines changed

src/libcore/benches/num/dec2flt/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::f64;
21
use test::Bencher;
32

43
#[bench]

src/libcore/benches/num/flt2dec/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod strategy {
55

66
use core::num::flt2dec::MAX_SIG_DIGITS;
77
use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
8-
use std::f64;
98
use std::io::Write;
109
use std::vec::Vec;
1110
use test::Bencher;

src/libcore/tests/iter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ fn test_cmp_by() {
7676
#[test]
7777
fn test_partial_cmp_by() {
7878
use core::cmp::Ordering;
79-
use core::f64;
8079

8180
let f = |x: i32, y: i32| (x * x).partial_cmp(&y);
8281
let xs = || [1, 2, 3, 4].iter().copied();
@@ -2894,7 +2893,7 @@ fn test_is_sorted() {
28942893
assert!(![1, 3, 2].iter().is_sorted());
28952894
assert!([0].iter().is_sorted());
28962895
assert!(std::iter::empty::<i32>().is_sorted());
2897-
assert!(![0.0, 1.0, std::f32::NAN].iter().is_sorted());
2896+
assert!(![0.0, 1.0, f32::NAN].iter().is_sorted());
28982897
assert!([-2, -1, 0, 3].iter().is_sorted());
28992898
assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs()));
29002899
assert!(!["c", "bb", "aaa"].iter().is_sorted());

src/libcore/tests/num/dec2flt/rawfp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use core::num::dec2flt::rawfp::RawFloat;
22
use core::num::dec2flt::rawfp::{fp_to_float, next_float, prev_float, round_normal};
33
use core::num::diy_float::Fp;
4-
use std::f32;
5-
use std::f64;
64

75
fn integer_decode(f: f64) -> (u64, i16, i8) {
86
RawFloat::integer_decode(f)

src/libcore/tests/num/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ test_impl_from! { test_u32f64, u32, f64 }
205205
// Float -> Float
206206
#[test]
207207
fn test_f32f64() {
208-
use core::f32;
209-
210208
let max: f64 = f32::MAX.into();
211209
assert_eq!(max as f32, f32::MAX);
212210
assert!(max.is_normal());
@@ -704,5 +702,5 @@ macro_rules! test_float {
704702
};
705703
}
706704

707-
test_float!(f32, f32, ::core::f32::INFINITY, ::core::f32::NEG_INFINITY, ::core::f32::NAN);
708-
test_float!(f64, f64, ::core::f64::INFINITY, ::core::f64::NEG_INFINITY, ::core::f64::NAN);
705+
test_float!(f32, f32, f32::INFINITY, f32::NEG_INFINITY, f32::NAN);
706+
test_float!(f64, f64, f64::INFINITY, f64::NEG_INFINITY, f64::NAN);

src/libcore/tests/ops.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,23 @@ fn test_range_inclusive() {
6161

6262
#[test]
6363
fn test_range_is_empty() {
64-
use core::f32::*;
65-
6664
assert!(!(0.0..10.0).is_empty());
6765
assert!((-0.0..0.0).is_empty());
6866
assert!((10.0..0.0).is_empty());
6967

70-
assert!(!(NEG_INFINITY..INFINITY).is_empty());
71-
assert!((EPSILON..NAN).is_empty());
72-
assert!((NAN..EPSILON).is_empty());
73-
assert!((NAN..NAN).is_empty());
68+
assert!(!(f32::NEG_INFINITY..f32::INFINITY).is_empty());
69+
assert!((f32::EPSILON..f32::NAN).is_empty());
70+
assert!((f32::NAN..f32::EPSILON).is_empty());
71+
assert!((f32::NAN..f32::NAN).is_empty());
7472

7573
assert!(!(0.0..=10.0).is_empty());
7674
assert!(!(-0.0..=0.0).is_empty());
7775
assert!((10.0..=0.0).is_empty());
7876

79-
assert!(!(NEG_INFINITY..=INFINITY).is_empty());
80-
assert!((EPSILON..=NAN).is_empty());
81-
assert!((NAN..=EPSILON).is_empty());
82-
assert!((NAN..=NAN).is_empty());
77+
assert!(!(f32::NEG_INFINITY..=f32::INFINITY).is_empty());
78+
assert!((f32::EPSILON..=f32::NAN).is_empty());
79+
assert!((f32::NAN..=f32::EPSILON).is_empty());
80+
assert!((f32::NAN..=f32::NAN).is_empty());
8381
}
8482

8583
#[test]

src/libcore/tests/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ fn test_is_sorted() {
17091709
assert!(![1, 3, 2].is_sorted());
17101710
assert!([0].is_sorted());
17111711
assert!(empty.is_sorted());
1712-
assert!(![0.0, 1.0, std::f32::NAN].is_sorted());
1712+
assert!(![0.0, 1.0, f32::NAN].is_sorted());
17131713
assert!([-2, -1, 0, 3].is_sorted());
17141714
assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
17151715
assert!(!["c", "bb", "aaa"].is_sorted());

src/libcore/tests/tuple.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::cmp::Ordering::{Equal, Greater, Less};
2-
use std::f64::NAN;
32

43
#[test]
54
fn test_clone() {
@@ -34,12 +33,12 @@ fn test_partial_ord() {
3433
assert!(big >= small);
3534
assert!(big >= big);
3635

37-
assert!(!((1.0f64, 2.0f64) < (NAN, 3.0)));
38-
assert!(!((1.0f64, 2.0f64) <= (NAN, 3.0)));
39-
assert!(!((1.0f64, 2.0f64) > (NAN, 3.0)));
40-
assert!(!((1.0f64, 2.0f64) >= (NAN, 3.0)));
41-
assert!(((1.0f64, 2.0f64) < (2.0, NAN)));
42-
assert!(!((2.0f64, 2.0f64) < (2.0, NAN)));
36+
assert!(!((1.0f64, 2.0f64) < (f64::NAN, 3.0)));
37+
assert!(!((1.0f64, 2.0f64) <= (f64::NAN, 3.0)));
38+
assert!(!((1.0f64, 2.0f64) > (f64::NAN, 3.0)));
39+
assert!(!((1.0f64, 2.0f64) >= (f64::NAN, 3.0)));
40+
assert!(((1.0f64, 2.0f64) < (2.0, f64::NAN)));
41+
assert!(!((2.0f64, 2.0f64) < (2.0, f64::NAN)));
4342
}
4443

4544
#[test]

0 commit comments

Comments
 (0)