From fc2f04083e9737459de0e1b5a150ca74101d8eeb Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sat, 17 May 2025 10:15:59 +0000 Subject: [PATCH] refactor(allocator/vec): clarify comment (#11071) Follow-on after #10884. Clarify comment as to why `as u32` is valid here. --- crates/oxc_allocator/src/vec2/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/oxc_allocator/src/vec2/mod.rs b/crates/oxc_allocator/src/vec2/mod.rs index f8faedbe0fbef..c0903ded421ba 100644 --- a/crates/oxc_allocator/src/vec2/mod.rs +++ b/crates/oxc_allocator/src/vec2/mod.rs @@ -1171,9 +1171,7 @@ impl<'bump, T: 'bump> Vec<'bump, T> { #[inline] #[expect(clippy::cast_possible_truncation)] pub unsafe fn set_len(&mut self, new_len: usize) { - // `new_len as u32` is safe because caller must ensure that - // `new_len` is less than or equal to `u32::MAX`, otherwise - // it is UB. + // Caller guarantees `new_len <= u32::MAX`, so `new_len as u32` cannot truncate `new_len` self.buf.len = new_len as u32; }