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
4 changes: 0 additions & 4 deletions crates/oxc_allocator/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub trait Alloc {
/// # Panics
///
/// Panics if reserving space for `layout` fails.
#[expect(dead_code)]
fn alloc(&self, layout: Layout) -> NonNull<u8>;

/// Deallocate the memory referenced by `ptr`.
Expand All @@ -36,7 +35,6 @@ pub trait Alloc {
///
/// * `ptr` must denote a block of memory currently allocated via this allocator.
/// * `layout` must be the same [`Layout`] that block was originally allocated with.
#[expect(dead_code)]
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout);

/// Grow an existing allocation to new [`Layout`].
Expand All @@ -56,7 +54,6 @@ pub trait Alloc {
/// * `ptr` must denote a block of memory currently allocated via this allocator.
/// * `old_layout` must be the same [`Layout`] that block was originally allocated with.
/// * `new_layout.size()` must be greater than or equal to `old_layout.size()`.
#[expect(dead_code)]
unsafe fn grow(&self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout) -> NonNull<u8>;

/// Shrink an existing allocation to new [`Layout`].
Expand All @@ -76,7 +73,6 @@ pub trait Alloc {
/// * `ptr` must denote a block of memory currently allocated via this allocator.
/// * `old_layout` must be the same [`Layout`] that block was originally allocated with.
/// * `new_layout.size()` must be smaller than or equal to `old_layout.size()`.
#[expect(dead_code)]
unsafe fn shrink(
&self,
ptr: NonNull<u8>,
Expand Down
17 changes: 9 additions & 8 deletions crates/oxc_allocator/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ use std::{
slice::SliceIndex,
};

use crate::vec2::Vec as InnerVec;
#[cfg(any(feature = "serialize", test))]
use oxc_estree::{ConcatElement, ESTree, SequenceSerializer, Serializer as ESTreeSerializer};
use bumpalo::Bump;
#[cfg(any(feature = "serialize", test))]
use serde::{Serialize, Serializer as SerdeSerializer};

use crate::{Allocator, Box};
#[cfg(any(feature = "serialize", test))]
use oxc_estree::{ConcatElement, ESTree, SequenceSerializer, Serializer as ESTreeSerializer};

use crate::{Allocator, Box, vec2::Vec as InnerVec};

/// A `Vec` without [`Drop`], which stores its data in the arena allocator.
///
Expand All @@ -34,7 +35,7 @@ use crate::{Allocator, Box};
/// Static checks make this impossible to do. [`Vec::new_in`] and all other methods which create
/// a [`Vec`] will refuse to compile if called with a [`Drop`] type.
#[derive(PartialEq, Eq)]
pub struct Vec<'alloc, T>(InnerVec<'alloc, T>);
pub struct Vec<'alloc, T>(InnerVec<'alloc, T, Bump>);

/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
unsafe impl<T> Send for Vec<'_, T> {}
Expand Down Expand Up @@ -167,7 +168,7 @@ impl<'alloc, T> Vec<'alloc, T> {
}

impl<'alloc, T> ops::Deref for Vec<'alloc, T> {
type Target = InnerVec<'alloc, T>;
type Target = InnerVec<'alloc, T, Bump>;

#[inline]
fn deref(&self) -> &Self::Target {
Expand All @@ -177,13 +178,13 @@ impl<'alloc, T> ops::Deref for Vec<'alloc, T> {

impl<'alloc, T> ops::DerefMut for Vec<'alloc, T> {
#[inline]
fn deref_mut(&mut self) -> &mut InnerVec<'alloc, T> {
fn deref_mut(&mut self) -> &mut InnerVec<'alloc, T, Bump> {
&mut self.0
}
}

impl<'alloc, T> IntoIterator for Vec<'alloc, T> {
type IntoIter = <InnerVec<'alloc, T> as IntoIterator>::IntoIter;
type IntoIter = <InnerVec<'alloc, T, Bump> as IntoIterator>::IntoIter;
type Item = T;

#[inline(always)]
Expand Down
Loading
Loading