You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Truncate vector to new length, dropping any items after `len`.
///
/// # Safety
///
/// Safe as long as `len <= self.capacity()`.
unsafefntruncate_unchecked(&mutself,len:usize){
debug_assert!(len <= self.capacity());
self.length = len asu16;
}
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
minimal-lexical/src/stackvec.rs
Lines 155 to 163 in e997c46
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).The text was updated successfully, but these errors were encountered: