Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions crates/oxc_allocator/src/vec2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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) }
}
Expand Down Expand Up @@ -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 }
}
}
Expand Down Expand Up @@ -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
////////////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 0 additions & 9 deletions crates/oxc_allocator/src/vec2/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading