Skip to content

Commit 3d09892

Browse files
committed
cleanup: Perform some simplifications possible with the MSRV bump
1 parent 1ec5101 commit 3d09892

3 files changed

Lines changed: 3 additions & 36 deletions

File tree

library/compiler-builtins/libm/src/math/generic/sqrt.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,7 @@ mod tests {
419419
fn conformance_tests_f16() {
420420
let cases = [
421421
(f16::PI, 0x3f17_u16),
422-
// 10_000.0, using a hex literal for MSRV hack (Rust < 1.67 checks literal widths as
423-
// part of the AST, so the `cfg` is irrelevant here).
424-
(f16::from_bits(0x70e2), 0x5640_u16),
422+
(10000.0_f16, 0x5640_u16),
425423
(f16::from_bits(0x0000000f), 0x13bf_u16),
426424
(f16::INFINITY, f16::INFINITY.to_bits()),
427425
];

library/compiler-builtins/libm/src/math/support/float_traits.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unknown_lints)] // FIXME(msrv) we shouldn't need this
2-
31
use core::{fmt, mem, ops};
42

53
use super::int_traits::{CastFrom, Int, MinInt};
@@ -289,10 +287,7 @@ macro_rules! float_impl {
289287
cfg_if! {
290288
// fma is not yet available in `core`
291289
if #[cfg(intrinsics_enabled)] {
292-
// FIXME(msrv,bench): once our benchmark rustc version is above the
293-
// 2022-09-23 nightly, this can be removed.
294-
#[allow(unused_unsafe)]
295-
unsafe { core::intrinsics::$fma_intrinsic(self, y, z) }
290+
core::intrinsics::$fma_intrinsic(self, y, z)
296291
} else {
297292
super::super::$fma_fn(self, y, z)
298293
}

library/compiler-builtins/libm/src/math/support/hex_float.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const fn parse_finite(
121121
Ok(Parsed { sig, exp }) => (sig, exp),
122122
};
123123

124-
let mut round_bits = u128_ilog2(sig) as i32 - sig_bits as i32;
124+
let mut round_bits = sig.ilog2() as i32 - sig_bits as i32;
125125

126126
// Round at least up to min_lsb
127127
if exp < min_lsb - round_bits {
@@ -299,29 +299,11 @@ const fn parse_hex(mut b: &[u8]) -> Result<Parsed, HexFloatParseError> {
299299
));
300300
};
301301

302-
{
303-
let e;
304-
if negate_exp {
305-
e = (exp as i64) - (pexp as i64);
306-
} else {
307-
e = (exp as i64) + (pexp as i64);
308-
};
309-
310-
exp = if e < i32::MIN as i64 {
311-
i32::MIN
312-
} else if e > i32::MAX as i64 {
313-
i32::MAX
314-
} else {
315-
e as i32
316-
};
317-
}
318-
/* FIXME(msrv): once MSRV >= 1.66, replace the above workaround block with:
319302
if negate_exp {
320303
exp = exp.saturating_sub_unsigned(pexp);
321304
} else {
322305
exp = exp.saturating_add_unsigned(pexp);
323306
};
324-
*/
325307

326308
Ok(Parsed { sig, exp })
327309
}
@@ -342,14 +324,6 @@ const fn hex_digit(c: u8) -> Option<u8> {
342324
}
343325
}
344326

345-
/* FIXME(msrv): vendor some things that are not const stable at our MSRV */
346-
347-
/// `u128::ilog2`
348-
const fn u128_ilog2(v: u128) -> u32 {
349-
assert!(v != 0);
350-
u128::BITS - 1 - v.leading_zeros()
351-
}
352-
353327
#[cfg(any(test, feature = "unstable-public-internals"))]
354328
mod hex_fmt {
355329
use core::fmt;

0 commit comments

Comments
 (0)