Description
Description
I just noticed the miri_to_const
function. This seems to duplicate a bunch of the logic in try_destructure_mir_constant_for_diagnostics
, maybe it would make sense to fully migrate to that query instead?
In particular the current logic is partially wrong: it has support for ConstValue::Indirect
arrays of floats. However, using from_le_bytes
to convert interpreter floats to an f32
is going to go wrong on big-endian targets. You need to take into account the endianess of the current compiler session. Or ideally you just use all the functions that already exist in rustc to work with interpreter data, e.g. Allocation::read_scalar
.
(Also, we are using "Miri" as the name for the tool these days, so the function is somewhat misnamed. This is really just converting a MIR constant into a Clippy constant.)
Version
No response
Additional Labels
No response