Skip to content

Commit 2adb43d

Browse files
eduardosmAmanieu
authored andcommitted
Avoid legacy numeric constants
1 parent 89a6142 commit 2adb43d

File tree

8 files changed

+33
-37
lines changed

8 files changed

+33
-37
lines changed

crates/core_arch/src/aarch64/test_support.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::core_arch::{aarch64::neon::*, arm_shared::*, simd::*};
2-
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
2+
use std::{mem::transmute, vec::Vec};
33

44
macro_rules! V_u64 {
55
() => {
@@ -23,11 +23,11 @@ macro_rules! V_f64 {
2323
-1.0f64,
2424
1.2f64,
2525
2.4f64,
26-
std::f64::MAX,
27-
std::f64::MIN,
28-
std::f64::INFINITY,
29-
std::f64::NEG_INFINITY,
30-
std::f64::NAN,
26+
f64::MAX,
27+
f64::MIN,
28+
f64::INFINITY,
29+
f64::NEG_INFINITY,
30+
f64::NAN,
3131
]
3232
};
3333
}

crates/core_arch/src/arm_shared/neon/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10124,7 +10124,7 @@ mod tests {
1012410124
use crate::core_arch::arm::*;
1012510125
use crate::core_arch::arm_shared::test_support::*;
1012610126
use crate::core_arch::simd::*;
10127-
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
10127+
use std::{mem::transmute, vec::Vec};
1012810128
use stdarch_test::simd_test;
1012910129

1013010130
#[simd_test(enable = "neon")]

crates/core_arch/src/arm_shared/test_support.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::core_arch::arm::*;
55
use crate::core_arch::aarch64::*;
66

77
use crate::core_arch::simd::*;
8-
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
8+
use std::{mem::transmute, vec::Vec};
99

1010
macro_rules! V_u8 {
1111
() => {
@@ -100,11 +100,11 @@ macro_rules! V_f32 {
100100
-1.0f32,
101101
1.2f32,
102102
2.4f32,
103-
std::f32::MAX,
104-
std::f32::MIN,
105-
std::f32::INFINITY,
106-
std::f32::NEG_INFINITY,
107-
std::f32::NAN,
103+
f32::MAX,
104+
f32::MIN,
105+
f32::INFINITY,
106+
f32::NEG_INFINITY,
107+
f32::NAN,
108108
]
109109
};
110110
}

crates/core_arch/src/powerpc/altivec.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -4680,7 +4680,7 @@ mod tests {
46804680
let a: vector_float = transmute(f32x4::new($($a),+));
46814681

46824682
let d: vector_float = transmute(f32x4::new($($d),+));
4683-
let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(std::f32::EPSILON)));
4683+
let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(f32::EPSILON)));
46844684
let e = m32x4::new(true, true, true, true);
46854685
assert_eq!(e, r);
46864686
}
@@ -6610,10 +6610,7 @@ mod tests {
66106610
let r8: vector_float = transmute(f32x4::new(0.0, 536870900.0, 536870900.0, 5.25));
66116611

66126612
let check = |a, b| {
6613-
let r = transmute(vec_cmple(
6614-
vec_abs(vec_sub(a, b)),
6615-
vec_splats(std::f32::EPSILON),
6616-
));
6613+
let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
66176614
let e = m32x4::new(true, true, true, true);
66186615
assert_eq!(e, r);
66196616
};
@@ -6662,10 +6659,7 @@ mod tests {
66626659
let r8: vector_float = transmute(f32x4::new(-268435460.0, 268435460.0, 268435460.0, 5.25));
66636660

66646661
let check = |a, b| {
6665-
let r = transmute(vec_cmple(
6666-
vec_abs(vec_sub(a, b)),
6667-
vec_splats(std::f32::EPSILON),
6668-
));
6662+
let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
66696663
println!("{:?} {:?}", a, b);
66706664
let e = m32x4::new(true, true, true, true);
66716665
assert_eq!(e, r);

crates/core_arch/src/wasm32/simd128.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -5646,13 +5646,13 @@ mod tests {
56465646
test_bop!(f32x4[f32; 4] | f32x4_min[f32x4_min_test]:
56475647
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [0., -3., -4., 8.]);
56485648
test_bop!(f32x4[f32; 4] | f32x4_min[f32x4_min_test_nan]:
5649-
([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN])
5650-
=> [0., -3., -4., std::f32::NAN]);
5649+
([0., -1., 7., 8.], [1., -3., -4., f32::NAN])
5650+
=> [0., -3., -4., f32::NAN]);
56515651
test_bop!(f32x4[f32; 4] | f32x4_max[f32x4_max_test]:
56525652
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -1., 7., 10.]);
56535653
test_bop!(f32x4[f32; 4] | f32x4_max[f32x4_max_test_nan]:
5654-
([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN])
5655-
=> [1., -1., 7., std::f32::NAN]);
5654+
([0., -1., 7., 8.], [1., -3., -4., f32::NAN])
5655+
=> [1., -1., 7., f32::NAN]);
56565656
test_bop!(f32x4[f32; 4] | f32x4_add[f32x4_add_test]:
56575657
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -4., 3., 18.]);
56585658
test_bop!(f32x4[f32; 4] | f32x4_sub[f32x4_sub_test]:
@@ -5667,13 +5667,13 @@ mod tests {
56675667
test_bop!(f64x2[f64; 2] | f64x2_min[f64x2_min_test]:
56685668
([0., -1.], [1., -3.]) => [0., -3.]);
56695669
test_bop!(f64x2[f64; 2] | f64x2_min[f64x2_min_test_nan]:
5670-
([7., 8.], [-4., std::f64::NAN])
5671-
=> [ -4., std::f64::NAN]);
5670+
([7., 8.], [-4., f64::NAN])
5671+
=> [ -4., f64::NAN]);
56725672
test_bop!(f64x2[f64; 2] | f64x2_max[f64x2_max_test]:
56735673
([0., -1.], [1., -3.]) => [1., -1.]);
56745674
test_bop!(f64x2[f64; 2] | f64x2_max[f64x2_max_test_nan]:
5675-
([7., 8.], [ -4., std::f64::NAN])
5676-
=> [7., std::f64::NAN]);
5675+
([7., 8.], [ -4., f64::NAN])
5676+
=> [7., f64::NAN]);
56775677
test_bop!(f64x2[f64; 2] | f64x2_add[f64x2_add_test]:
56785678
([0., -1.], [1., -3.]) => [1., -4.]);
56795679
test_bop!(f64x2[f64; 2] | f64x2_sub[f64x2_sub_test]:

crates/core_arch/src/x86/sha.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ pub unsafe fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m12
121121
#[cfg(test)]
122122
mod tests {
123123
use std::{
124-
f32,
125-
f64::{self, NAN},
126-
i32,
124+
f32, f64,
127125
mem::{self, transmute},
128126
};
129127

@@ -133,6 +131,8 @@ mod tests {
133131
};
134132
use stdarch_test::simd_test;
135133

134+
const NAN: f64 = f64::NAN;
135+
136136
#[simd_test(enable = "sha")]
137137
#[allow(overflowing_literals)]
138138
unsafe fn test_mm_sha1msg1_epu32() {

crates/core_arch/src/x86/sse.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2002,11 +2002,13 @@ pub unsafe fn _mm_stream_ps(mem_addr: *mut f32, a: __m128) {
20022002
#[cfg(test)]
20032003
mod tests {
20042004
use crate::{hint::black_box, mem::transmute, ptr};
2005-
use std::{boxed, f32::NAN};
2005+
use std::boxed;
20062006
use stdarch_test::simd_test;
20072007

20082008
use crate::core_arch::{simd::*, x86::*};
20092009

2010+
const NAN: f32 = f32::NAN;
2011+
20102012
#[simd_test(enable = "sse")]
20112013
unsafe fn test_mm_add_ps() {
20122014
let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0);

crates/core_arch/src/x86/sse2.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3046,14 +3046,14 @@ mod tests {
30463046
hint::black_box,
30473047
};
30483048
use std::{
3049-
boxed, f32,
3050-
f64::{self, NAN},
3051-
i32,
3049+
boxed, f32, f64,
30523050
mem::{self, transmute},
30533051
ptr,
30543052
};
30553053
use stdarch_test::simd_test;
30563054

3055+
const NAN: f64 = f64::NAN;
3056+
30573057
#[test]
30583058
fn test_mm_pause() {
30593059
unsafe { _mm_pause() }

0 commit comments

Comments
 (0)