Skip to content

Commit 5f33085

Browse files
more clear NAN names and fix broken_floats logic
Co-authored-by: Jubilee <[email protected]>
1 parent 53e1a2e commit 5f33085

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Diff for: tests/ui/consts/const-float-bits-conv.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ fn f32() {
4646

4747
// Check that NaNs roundtrip their bits regardless of signalingness
4848
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
49-
const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
50-
const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
49+
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
50+
const QUIET_NAN: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
51+
const SIGNALING_NAN: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
5152

52-
const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
53-
const_assert!(f32::from_bits(MASKED_NAN2).is_nan());
54-
const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
53+
const_assert!(f32::from_bits(QUIET_NAN).is_nan());
54+
const_assert!(f32::from_bits(SIGNALING_NAN).is_nan());
55+
const_assert!(f32::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
5556
if !has_broken_floats() {
56-
const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
57+
const_assert!(f32::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
5758
}
5859
}
5960

@@ -75,14 +76,15 @@ fn f64() {
7576

7677
// Check that NaNs roundtrip their bits regardless of signalingness
7778
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
78-
const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA;
79-
const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
79+
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
80+
const QUIET_NAN: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
81+
const SIGNALING_NAN: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA;
8082

81-
const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
82-
const_assert!(f64::from_bits(MASKED_NAN2).is_nan());
83-
const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
83+
const_assert!(f64::from_bits(QUIET_NAN).is_nan());
84+
const_assert!(f64::from_bits(SIGNALING_NAN).is_nan());
85+
const_assert!(f64::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
8486
if !has_broken_floats() {
85-
const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
87+
const_assert!(f64::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
8688
}
8789
}
8890

0 commit comments

Comments
 (0)