cleanup: Perform some simplifications possible with the MSRV bump
This commit is contained in:
parent
1ec5101f20
commit
3d0989266d
3 changed files with 3 additions and 36 deletions
|
|
@ -419,9 +419,7 @@ mod tests {
|
|||
fn conformance_tests_f16() {
|
||||
let cases = [
|
||||
(f16::PI, 0x3f17_u16),
|
||||
// 10_000.0, using a hex literal for MSRV hack (Rust < 1.67 checks literal widths as
|
||||
// part of the AST, so the `cfg` is irrelevant here).
|
||||
(f16::from_bits(0x70e2), 0x5640_u16),
|
||||
(10000.0_f16, 0x5640_u16),
|
||||
(f16::from_bits(0x0000000f), 0x13bf_u16),
|
||||
(f16::INFINITY, f16::INFINITY.to_bits()),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![allow(unknown_lints)] // FIXME(msrv) we shouldn't need this
|
||||
|
||||
use core::{fmt, mem, ops};
|
||||
|
||||
use super::int_traits::{CastFrom, Int, MinInt};
|
||||
|
|
@ -289,10 +287,7 @@ macro_rules! float_impl {
|
|||
cfg_if! {
|
||||
// fma is not yet available in `core`
|
||||
if #[cfg(intrinsics_enabled)] {
|
||||
// FIXME(msrv,bench): once our benchmark rustc version is above the
|
||||
// 2022-09-23 nightly, this can be removed.
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe { core::intrinsics::$fma_intrinsic(self, y, z) }
|
||||
core::intrinsics::$fma_intrinsic(self, y, z)
|
||||
} else {
|
||||
super::super::$fma_fn(self, y, z)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ const fn parse_finite(
|
|||
Ok(Parsed { sig, exp }) => (sig, exp),
|
||||
};
|
||||
|
||||
let mut round_bits = u128_ilog2(sig) as i32 - sig_bits as i32;
|
||||
let mut round_bits = sig.ilog2() as i32 - sig_bits as i32;
|
||||
|
||||
// Round at least up to min_lsb
|
||||
if exp < min_lsb - round_bits {
|
||||
|
|
@ -299,29 +299,11 @@ const fn parse_hex(mut b: &[u8]) -> Result<Parsed, HexFloatParseError> {
|
|||
));
|
||||
};
|
||||
|
||||
{
|
||||
let e;
|
||||
if negate_exp {
|
||||
e = (exp as i64) - (pexp as i64);
|
||||
} else {
|
||||
e = (exp as i64) + (pexp as i64);
|
||||
};
|
||||
|
||||
exp = if e < i32::MIN as i64 {
|
||||
i32::MIN
|
||||
} else if e > i32::MAX as i64 {
|
||||
i32::MAX
|
||||
} else {
|
||||
e as i32
|
||||
};
|
||||
}
|
||||
/* FIXME(msrv): once MSRV >= 1.66, replace the above workaround block with:
|
||||
if negate_exp {
|
||||
exp = exp.saturating_sub_unsigned(pexp);
|
||||
} else {
|
||||
exp = exp.saturating_add_unsigned(pexp);
|
||||
};
|
||||
*/
|
||||
|
||||
Ok(Parsed { sig, exp })
|
||||
}
|
||||
|
|
@ -342,14 +324,6 @@ const fn hex_digit(c: u8) -> Option<u8> {
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME(msrv): vendor some things that are not const stable at our MSRV */
|
||||
|
||||
/// `u128::ilog2`
|
||||
const fn u128_ilog2(v: u128) -> u32 {
|
||||
assert!(v != 0);
|
||||
u128::BITS - 1 - v.leading_zeros()
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "unstable-public-internals"))]
|
||||
mod hex_fmt {
|
||||
use core::fmt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue