Skip to content

refactor: replace allocator-api2 with bumpalo collections#400

Merged
branchseer merged 1 commit into
mainfrom
claude/festive-maxwell-JP5gZ
May 26, 2026
Merged

refactor: replace allocator-api2 with bumpalo collections#400
branchseer merged 1 commit into
mainfrom
claude/festive-maxwell-JP5gZ

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented May 26, 2026

Replace the generic allocator-api2 dependency with bumpalo's built-in collections API for simpler, more direct arena allocation.

Motivation

bumpalo pins its optional allocator-api2 dependency at ^0.2.8, which means bumpalo::Bump only implements allocator_api2::alloc::Allocator from the 0.2.x line. When Renovate proposes upgrading our direct allocator-api2 dependency 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 the Allocator trait in the dependency graph, and &Bump no longer satisfies the trait bound used by NativePath::clone_in / NativeStr::clone_in. The result is a compile error that can only be resolved by reverting the Renovate upgrade — until upstream bumpalo decides to bump its own allocator-api2 requirement.

Dropping allocator-api2 as a direct workspace dependency removes the pin we have no control over, eliminates the recurring Renovate noise, and lets bumpalo upgrades land independently. allocator-api2 0.2.x remains in the graph transitively (via hashbrown), but that's an internal concern of hashbrown and no longer ours to manage.

Summary

This refactor removes the allocator-api2 crate dependency across the codebase and consolidates on bumpalo for all arena-based allocations. The change simplifies the generic allocator abstraction to a concrete Bump allocator, reducing complexity while maintaining the same functionality.

Key Changes

  • native_str and fspy_shared: Simplified clone_in() methods to accept &Bump directly instead of generic Allocator trait bounds

    • NativeStr::clone_in() now uses bump.alloc_slice_copy() instead of manual Vec allocation and leak
    • NativePath::clone_in() delegates to the simplified NativeStr method
  • fspy arena: Updated to use bumpalo::collections::Vec instead of allocator_api2::vec::Vec

    • Changed Vec<PathAccess<'this>, &'this Bump> to Vec<'this, PathAccess<'this>> (bumpalo's syntax)
  • Dependencies:

    • Removed allocator-api2 from workspace and all crate dependencies
    • Updated bumpalo feature from allocator-api2 to collections
    • Added explicit bumpalo dependency to fspy_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

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).
@branchseer branchseer merged commit d02b257 into main May 26, 2026
17 checks passed
@branchseer branchseer deleted the claude/festive-maxwell-JP5gZ branch May 26, 2026 06:23
@branchseer branchseer mentioned this pull request May 26, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants