Resolve unnecessary_transmutes lints

These appeared in a later nightly. In compiler-builtins we can apply the
suggestion, but in `libm` we need to ignore them since `fx::from_bits`
is not `const` at the MSRV.

`clippy::uninlined_format_args` also seems to have gotten stricter, so
fix those here.
This commit is contained in:
Trevor Gross
2025-04-29 21:04:30 +00:00
committed by Trevor Gross
parent 975617e8d4
commit 8d789ea8f1
6 changed files with 32 additions and 48 deletions

View File

@@ -452,11 +452,7 @@ mod tests {
} else {
pow(base, exponent) == expected
},
"{} ** {} was {} instead of {}",
base,
exponent,
res,
expected
"{base} ** {exponent} was {res} instead of {expected}",
);
}
@@ -486,10 +482,7 @@ mod tests {
} else {
exp == res
},
"test for {} was {} instead of {}",
val,
res,
exp
"test for {val} was {res} instead of {exp}",
);
})
});

View File

@@ -1,3 +1,5 @@
#![allow(unknown_lints)] // FIXME(msrv) we shouldn't need this
use core::{fmt, mem, ops};
use super::int_traits::{CastFrom, Int, MinInt};
@@ -344,24 +346,28 @@ float_impl!(
/* FIXME(msrv): vendor some things that are not const stable at our MSRV */
/// `f32::from_bits`
#[allow(unnecessary_transmutes)] // lint appears in newer versions of Rust
pub const fn f32_from_bits(bits: u32) -> f32 {
// SAFETY: POD cast with no preconditions
unsafe { mem::transmute::<u32, f32>(bits) }
}
/// `f32::to_bits`
#[allow(unnecessary_transmutes)] // lint appears in newer versions of Rust
pub const fn f32_to_bits(x: f32) -> u32 {
// SAFETY: POD cast with no preconditions
unsafe { mem::transmute::<f32, u32>(x) }
}
/// `f64::from_bits`
#[allow(unnecessary_transmutes)] // lint appears in newer versions of Rust
pub const fn f64_from_bits(bits: u64) -> f64 {
// SAFETY: POD cast with no preconditions
unsafe { mem::transmute::<u64, f64>(bits) }
}
/// `f64::to_bits`
#[allow(unnecessary_transmutes)] // lint appears in newer versions of Rust
pub const fn f64_to_bits(x: f64) -> u64 {
// SAFETY: POD cast with no preconditions
unsafe { mem::transmute::<f64, u64>(x) }