diff --git a/apps/oxlint/Cargo.toml b/apps/oxlint/Cargo.toml index 8f2d8189db174..bc2da0bb74985 100644 --- a/apps/oxlint/Cargo.toml +++ b/apps/oxlint/Cargo.toml @@ -62,5 +62,5 @@ lazy-regex = { workspace = true } default = [] allocator = ["dep:mimalloc-safe"] oxlint2 = ["oxc_linter/oxlint2", "oxc_allocator/fixed_size", "dep:simdutf8"] -disable_oxlint2 = ["oxc_linter/disable_oxlint2", "oxc_allocator/disable_fixed_size"] +disable_oxlint2 = ["oxc_linter/disable_oxlint2"] force_test_reporter = ["oxc_linter/force_test_reporter"] diff --git a/crates/oxc_allocator/Cargo.toml b/crates/oxc_allocator/Cargo.toml index 038e09cd0493c..373bd2f0fd116 100644 --- a/crates/oxc_allocator/Cargo.toml +++ b/crates/oxc_allocator/Cargo.toml @@ -38,7 +38,6 @@ serde_json = { workspace = true } [features] bitset = [] fixed_size = ["from_raw_parts", "pool", "dep:oxc_ast_macros"] -disable_fixed_size = [] from_raw_parts = [] pool = [] serialize = ["dep:serde", "oxc_estree/serialize"] diff --git a/crates/oxc_allocator/README.md b/crates/oxc_allocator/README.md index f385695f3284f..d9aecbb927979 100644 --- a/crates/oxc_allocator/README.md +++ b/crates/oxc_allocator/README.md @@ -35,7 +35,5 @@ This approach is significantly faster than using the system allocator for AST op - `track_allocations` - Count allocations and reallocations. For internal use only. The APIs provided by this feature are sketchy at best, and possibly undefined behavior. Do not enable this feature under any circumstances in production code. -- `disable_fixed_size` - Disables `fixed_size` feature. - Purpose is to prevent `--all-features` enabling fixed sized allocators. - `disable_track_allocations` - Disables `track_allocations` feature. Purpose is to prevent `--all-features` enabling allocation tracking. diff --git a/crates/oxc_allocator/src/lib.rs b/crates/oxc_allocator/src/lib.rs index 929380d8d987d..dd1dad1743e82 100644 --- a/crates/oxc_allocator/src/lib.rs +++ b/crates/oxc_allocator/src/lib.rs @@ -32,9 +32,6 @@ //! For internal use only. The APIs provided by this feature are sketchy at best, and possibly //! undefined behavior. Do not enable this feature under any circumstances in production code. //! -//! * `disable_fixed_size` - Disables `fixed_size` feature. -//! Purpose is to prevent `--all-features` enabling fixed sized allocators. -//! //! * `disable_track_allocations` - Disables `track_allocations` feature. //! Purpose is to prevent `--all-features` enabling allocation tracking. @@ -80,12 +77,7 @@ pub use vec::Vec; // Fixed size allocators are only supported on 64-bit little-endian platforms at present. // // Note: Importing the `fixed_size_constants` module would cause a compilation error on 32-bit systems. -#[cfg(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -))] +#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))] mod generated { #[cfg(debug_assertions)] mod assert_layouts; diff --git a/crates/oxc_allocator/src/pool/mod.rs b/crates/oxc_allocator/src/pool/mod.rs index f96359ef1748e..2a1de2f9d7a81 100644 --- a/crates/oxc_allocator/src/pool/mod.rs +++ b/crates/oxc_allocator/src/pool/mod.rs @@ -6,41 +6,16 @@ mod standard; use standard::StandardAllocatorPool; // Fixed size allocators are only supported on 64-bit little-endian platforms at present. -// They are only enabled if `fixed_size` feature enabled, and `disable_fixed_size` feature is not enabled. +// They are only enabled if `fixed_size` Cargo feature is enabled. // // Note: Importing the `fixed_size` module would cause a compilation error on 32-bit systems. -#[cfg(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -))] +#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))] mod fixed_size; -#[cfg(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -))] +#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))] use fixed_size::FixedSizeAllocatorPool; -#[cfg(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -))] +#[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))] pub use fixed_size::{FixedSizeAllocatorMetadata, free_fixed_size_allocator}; -// Dummy implementations of interfaces from `fixed_size`, just to stop clippy complaining. -// Seems to be necessary due to feature unification. -#[cfg(not(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -)))] -pub use standard::{FixedSizeAllocatorMetadata, free_fixed_size_allocator}; - /// A thread-safe pool for reusing [`Allocator`] instances to reduce allocation overhead. /// /// Uses either: @@ -51,20 +26,14 @@ pub use standard::{FixedSizeAllocatorMetadata, free_fixed_size_allocator}; /// Fixed-size allocator pool is created by [`AllocatorPool::new_fixed_size`]. /// /// Fixed-size allocators are only supported on 64-bit little-endian platforms at present, -/// and require the `fixed_size` Cargo feature to be enabled, and `disable_fixed_size` Cargo feature -/// to not be enabled. +/// and require the `fixed_size` Cargo feature to be enabled. #[repr(transparent)] pub struct AllocatorPool(AllocatorPoolInner); /// Inner type of [`AllocatorPool`], holding either a standard or fixed-size allocator pool. enum AllocatorPoolInner { Standard(StandardAllocatorPool), - #[cfg(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" - ))] + #[cfg(all(feature = "fixed_size", target_pointer_width = "64", target_endian = "little"))] FixedSize(FixedSizeAllocatorPool), } @@ -77,7 +46,7 @@ impl AllocatorPool { /// Create a new [`AllocatorPool`] for use across the specified number of threads, /// which uses fixed-size allocators (suitable for raw transfer). - #[cfg(all(feature = "fixed_size", not(feature = "disable_fixed_size")))] + #[cfg(feature = "fixed_size")] pub fn new_fixed_size(thread_count: usize) -> AllocatorPool { #[cfg(all(target_pointer_width = "64", target_endian = "little"))] { @@ -102,7 +71,6 @@ impl AllocatorPool { AllocatorPoolInner::Standard(pool) => pool.get(), #[cfg(all( feature = "fixed_size", - not(feature = "disable_fixed_size"), target_pointer_width = "64", target_endian = "little" ))] @@ -128,7 +96,6 @@ impl AllocatorPool { AllocatorPoolInner::Standard(pool) => pool.add(allocator), #[cfg(all( feature = "fixed_size", - not(feature = "disable_fixed_size"), target_pointer_width = "64", target_endian = "little" ))] diff --git a/crates/oxc_allocator/src/pool/standard.rs b/crates/oxc_allocator/src/pool/standard.rs index 81a574845dafb..b5a8b85eb03f2 100644 --- a/crates/oxc_allocator/src/pool/standard.rs +++ b/crates/oxc_allocator/src/pool/standard.rs @@ -44,50 +44,3 @@ impl StandardAllocatorPool { allocators.push(allocator); } } - -// Dummy implementations of interfaces from `fixed_size`, just to stop clippy complaining. -// Seems to be necessary due to feature unification. -#[cfg(not(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -)))] -#[allow( - dead_code, - missing_docs, - clippy::missing_safety_doc, - clippy::unused_self, - clippy::allow_attributes -)] -mod dummies { - use std::{ptr::NonNull, sync::atomic::AtomicBool}; - - use crate::Allocator; - - #[doc(hidden)] - pub struct FixedSizeAllocatorMetadata { - pub id: u32, - pub(crate) alloc_ptr: NonNull, - pub is_double_owned: AtomicBool, - } - - #[doc(hidden)] - pub unsafe fn free_fixed_size_allocator(_metadata_ptr: NonNull) { - unreachable!(); - } - - #[doc(hidden)] - impl Allocator { - pub unsafe fn fixed_size_metadata_ptr(&self) -> NonNull { - unreachable!(); - } - } -} -#[cfg(not(all( - feature = "fixed_size", - not(feature = "disable_fixed_size"), - target_pointer_width = "64", - target_endian = "little" -)))] -pub use dummies::*;