Skip to content

Commit 89d661f

Browse files
authored
Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnay
Don't import integer and float modules, use assoc consts 2 Follow up to #70777. I missed quite a lot of places. Partially because I wanted to keep the size of the last PR down, and partially because my regexes were not good enough :) r? @dtolnay
2 parents 78c64d0 + f7778d3 commit 89d661f

File tree

25 files changed

+52
-68
lines changed

25 files changed

+52
-68
lines changed

src/liballoc/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ unsafe impl<#[may_dangle] T, A: AllocRef> Drop for RawVec<T, A> {
608608

609609
#[inline]
610610
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
611-
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
611+
if mem::size_of::<usize>() < 8 && alloc_size > isize::MAX as usize {
612612
Err(CapacityOverflow)
613613
} else {
614614
Ok(())

src/liballoc/tests/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn trait_object() {
5050

5151
#[test]
5252
fn float_nan_ne() {
53-
let x = Arc::new(std::f32::NAN);
53+
let x = Arc::new(f32::NAN);
5454
assert!(x != x);
5555
assert!(!(x == x));
5656
}

src/liballoc/tests/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn test_range_large() {
475475

476476
#[test]
477477
fn test_range_inclusive_max_value() {
478-
let max = std::usize::MAX;
478+
let max = usize::MAX;
479479
let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect();
480480

481481
assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);

src/liballoc/tests/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn trait_object() {
5050

5151
#[test]
5252
fn float_nan_ne() {
53-
let x = Rc::new(std::f32::NAN);
53+
let x = Rc::new(f32::NAN);
5454
assert!(x != x);
5555
assert!(!(x == x));
5656
}

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]

0 commit comments

Comments
 (0)