This is technically sound as-is, because Limb is defined as an alias to either u32 or u64. But if in some future refactor Limb became a type with a real Drop impl, this code would become unsound.
Looping over the truncated elements and calling ptr::drop_in_place would future-proof this part of the code, while hopefully being optimised out by LLVM for the current Drop-less Limb types.
Description
https://github.com/Alexhuszagh/minimal-lexical/blob/e997c46656ebe83e696b866bd954da1fa3f64eef/src/stackvec.rs#L155-L163
This is technically sound as-is, because
Limb
is defined as an alias to eitheru32
oru64
. But if in some future refactorLimb
became a type with a realDrop
impl, this code would become unsound.Looping over the truncated elements and calling
ptr::drop_in_place
would future-proof this part of the code, while hopefully being optimised out by LLVM for the currentDrop
-lessLimb
types.Additional Context
I'm in the process of migrating Fuchsia to use
nom 7
, which depends onminimal-lexical 0.1
, and am opening issues in response to review comments (visible here: https://fuchsia-review.googlesource.com/c/fuchsia/+/589324).