refactor: replace allocator-api2 with bumpalo collections#400
Merged
Conversation
The allocator-api2 trait was only used to allow `bumpalo::Bump` to back the arena's `Vec` allocations. Switching to `bumpalo::collections::Vec` and `Bump::alloc_slice_copy` removes the abstraction layer, drops a workspace dependency, and unblocks future bumpalo upgrades (bumpalo still pins allocator-api2 to ^0.2.8, which prevents updating allocator-api2 to 0.4.x).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the generic
allocator-api2dependency withbumpalo's built-in collections API for simpler, more direct arena allocation.Motivation
bumpalopins its optionalallocator-api2dependency at^0.2.8, which meansbumpalo::Bumponly implementsallocator_api2::alloc::Allocatorfrom the 0.2.x line. When Renovate proposes upgrading our directallocator-api2dependency past 0.2.x (e.g. PR #384 tried to bump it to 0.4.0), the workspace ends up with two incompatible versions of theAllocatortrait in the dependency graph, and&Bumpno longer satisfies the trait bound used byNativePath::clone_in/NativeStr::clone_in. The result is a compile error that can only be resolved by reverting the Renovate upgrade — until upstreambumpalodecides to bump its ownallocator-api2requirement.Dropping
allocator-api2as a direct workspace dependency removes the pin we have no control over, eliminates the recurring Renovate noise, and letsbumpaloupgrades land independently.allocator-api2 0.2.xremains in the graph transitively (viahashbrown), but that's an internal concern ofhashbrownand no longer ours to manage.Summary
This refactor removes the
allocator-api2crate dependency across the codebase and consolidates onbumpalofor all arena-based allocations. The change simplifies the generic allocator abstraction to a concreteBumpallocator, reducing complexity while maintaining the same functionality.Key Changes
native_strandfspy_shared: Simplifiedclone_in()methods to accept&Bumpdirectly instead of genericAllocatortrait boundsNativeStr::clone_in()now usesbump.alloc_slice_copy()instead of manualVecallocation and leakNativePath::clone_in()delegates to the simplifiedNativeStrmethodfspyarena: Updated to usebumpalo::collections::Vecinstead ofallocator_api2::vec::VecVec<PathAccess<'this>, &'this Bump>toVec<'this, PathAccess<'this>>(bumpalo's syntax)Dependencies:
allocator-api2from workspace and all crate dependenciesbumpalofeature fromallocator-api2tocollectionsbumpalodependency tofspy_shared(was implicit before)Implementation Details
The change leverages
bumpalo's native collection types which are simpler and more ergonomic than the generic allocator abstraction. This reduces trait bounds and makes the code more readable while maintaining the same arena allocation semantics.https://claude.ai/code/session_01PbgnWekFEAwysNrpigCzCJ