diff --git a/crates/oxc_allocator/src/vec2/mod.rs b/crates/oxc_allocator/src/vec2/mod.rs index 56f50318e99fa..b1b8d83b0bbe3 100644 --- a/crates/oxc_allocator/src/vec2/mod.rs +++ b/crates/oxc_allocator/src/vec2/mod.rs @@ -870,7 +870,7 @@ impl<'bump, T: 'bump> Vec<'bump, T> { unsafe { let ptr = self.as_ptr(); let len = self.len(); - mem::forget(self); + // Don't need `mem::forget(self)` here, because `Vec` does not implement `Drop`. slice::from_raw_parts(ptr, len) } } @@ -895,7 +895,7 @@ impl<'bump, T: 'bump> Vec<'bump, T> { pub fn into_bump_slice_mut(mut self) -> &'bump mut [T] { let ptr = self.as_mut_ptr(); let len = self.len(); - mem::forget(self); + // Don't need `mem::forget(self)` here, because `Vec` does not implement `Drop`. unsafe { slice::from_raw_parts_mut(ptr, len) } } @@ -2244,7 +2244,7 @@ impl<'bump, T: 'bump> IntoIterator for Vec<'bump, T> { } else { begin.add(self.len()) as *const T }; - mem::forget(self); + // Don't need `mem::forget(self)` here, because `Vec` does not implement `Drop`. IntoIter { phantom: PhantomData, ptr: begin, end } } } @@ -2453,18 +2453,6 @@ impl<'bump, T: 'bump> BorrowMut<[T]> for Vec<'bump, T> { } } -impl<'bump, T> Drop for Vec<'bump, T> { - fn drop(&mut self) { - unsafe { - // use drop for [T] - // use a raw slice to refer to the elements of the vector as weakest necessary type; - // could avoid questions of validity in certain cases - ptr::drop_in_place(ptr::slice_from_raw_parts_mut(self.as_mut_ptr(), self.len)) - } - // RawVec handles deallocation - } -} - //////////////////////////////////////////////////////////////////////////////// // Clone-on-write //////////////////////////////////////////////////////////////////////////////// diff --git a/crates/oxc_allocator/src/vec2/raw_vec.rs b/crates/oxc_allocator/src/vec2/raw_vec.rs index b232791391db5..d272a82c779b6 100644 --- a/crates/oxc_allocator/src/vec2/raw_vec.rs +++ b/crates/oxc_allocator/src/vec2/raw_vec.rs @@ -702,15 +702,6 @@ impl<'a, T> RawVec<'a, T> { } } -impl<'a, T> Drop for RawVec<'a, T> { - /// Frees the memory owned by the RawVec *without* trying to Drop its contents. - fn drop(&mut self) { - unsafe { - self.dealloc_buffer(); - } - } -} - // We need to guarantee the following: // * We don't ever allocate `> isize::MAX` byte-size objects // * We don't overflow `usize::MAX` and actually allocate too little