Skip to content

refactor(all): import arena Box and Vec as ArenaBox / ArenaVec#23747

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_
Jun 24, 2026
Merged

refactor(all): import arena Box and Vec as ArenaBox / ArenaVec#23747
graphite-app[bot] merged 1 commit into
mainfrom
om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jun 23, 2026

Copy link
Copy Markdown
Member

Pure refactor.

Use ArenaBox and ArenaVec everywhere for the arena-allocated types from oxc_allocator, instead of plain Box and Vec.

This disambiguates when Vec is oxc_allocator::Vec and when it's std::vec::Vec, making code clearer to follow.

Previously it was easy to confuse the two, and such confusion led to UB in Traverse (fixed in #23745).

Ditto other arena types - ArenaHashMap, ArenaHashSet, ArenaStringBuilder.

The only exceptions are:

  1. Inside oxc_allocator crate itself.
  2. AST type definitions.
  3. Generated code (migrated separately in refactor(all): use ArenaBox and ArenaVec in generated code #23749).

overlookmotel commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added A-linter Area - Linter A-parser Area - Parser A-semantic Area - Semantic A-cli Area - CLI A-minifier Area - Minifier A-ast Area - AST A-transformer Area - Transformer / Transpiler A-ast-tools Area - AST tools A-formatter Area - Formatter labels Jun 23, 2026
@overlookmotel overlookmotel marked this pull request as ready for review June 23, 2026 20:09
Copilot AI review requested due to automatic review settings June 23, 2026 20:09
@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_ (2ea7dcc) with om/06-23-refactor_allocator_export_arenabox_and_arenavec_aliases (3f1e6c5)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the codebase to consistently use oxc_allocator’s arena-allocated type aliases (ArenaBox, ArenaVec, ArenaHashMap, ArenaHashSet, ArenaStringBuilder, etc.) instead of importing/using plain Box/Vec/HashMap/HashSet directly, improving clarity about which collections are arena-backed.

Changes:

  • Updated imports and type annotations across many crates to prefer Arena* aliases for arena-allocated types.
  • Adjusted function signatures/return types and a few docs/comments to reflect the renamed arena types.
  • Updated several formatter/linter/parser implementations to use ArenaStringBuilder / ArenaVec consistently.

Reviewed changes

Copilot reviewed 101 out of 101 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tasks/rulegen/src/main.rs Switches parsed argument vec types to ArenaVec and updates imports accordingly.
tasks/ast_tools/src/parse/parse.rs Allows parsing type names ArenaBox/ArenaVec as arena Box/Vec equivalents.
napi/parser/src/raw_transfer_types.rs Migrates transfer structs/helpers from allocator Vec to ArenaVec.
crates/oxc_traverse/src/context/scoping.rs Updates scope insertion API to take &ArenaVec<'a, Statement<'a>>.
crates/oxc_traverse/src/context/mod.rs Updates TraverseCtx arena allocation docs and ArenaVec statement APIs.
crates/oxc_transformer/src/jsx/jsx_impl.rs Fixes JSX transform API to accept ArenaVec<'a, JSXChild<'a>>.
crates/oxc_transformer_plugins/src/replace_global_defines.rs Uses ArenaBox in imports and parameter types.
crates/oxc_syntax/src/module_record.rs Migrates module record containers to ArenaHashMap/ArenaVec.
crates/oxc_str/src/ident.rs Updates arena ident map alias to ArenaHashMap.
crates/oxc_span/src/cmp.rs Uses ArenaBox/ArenaVec for ContentEq blanket impls and imports.
crates/oxc_semantic/src/builder.rs Migrates decorator vec references to ArenaVec.
crates/oxc_regular_expression/src/parser/pattern_parser/pattern_parser_impl.rs Migrates regex parser allocations to ArenaBox/ArenaVec.
crates/oxc_regular_expression/src/ast.rs Updates regex AST node storage to ArenaBox/ArenaVec.
crates/oxc_react_compiler/src/lib.rs Uses ArenaVec for preserved comments buffer.
crates/oxc_react_compiler/src/convert_ast_reverse.rs Switches builder output vectors/boxes and string building to arena aliases.
crates/oxc_parser/src/ts/types.rs Migrates TS type parsing APIs to ArenaBox/ArenaVec.
crates/oxc_parser/src/ts/statement.rs Migrates TS statement parsing APIs to ArenaBox/ArenaVec.
crates/oxc_parser/src/module_record.rs Uses ArenaVec inside the module record builder.
crates/oxc_parser/src/lib.rs Updates parser return/token storage and statement reparsing APIs to ArenaVec.
crates/oxc_parser/src/lexer/unicode.rs Switches lexer string building to ArenaStringBuilder.
crates/oxc_parser/src/lexer/template.rs Switches template literal building to ArenaStringBuilder.
crates/oxc_parser/src/lexer/string.rs Switches string literal building to ArenaStringBuilder.
crates/oxc_parser/src/lexer/identifier.rs Switches identifier escape building to ArenaStringBuilder.
crates/oxc_parser/src/jsx/mod.rs Migrates JSX parsing allocations and child vectors to arena aliases.
crates/oxc_parser/src/js/statement.rs Migrates statement parsing allocations to ArenaBox/ArenaVec.
crates/oxc_parser/src/js/object.rs Migrates object parsing allocations to ArenaBox.
crates/oxc_parser/src/js/module.rs Migrates module parsing allocations/specifier vectors to ArenaVec/ArenaBox.
crates/oxc_parser/src/js/function.rs Migrates function parsing allocations/parameter lists to arena aliases.
crates/oxc_parser/src/js/expression.rs Migrates expression parsing allocations/argument vectors to arena aliases.
crates/oxc_parser/src/js/declaration.rs Migrates variable declaration parsing allocations to ArenaBox.
crates/oxc_parser/src/js/class.rs Migrates class parsing allocations and implements/extends vectors to arena aliases.
crates/oxc_parser/src/js/binding.rs Migrates binding pattern parsing allocations to ArenaBox.
crates/oxc_parser/src/js/arrow.rs Migrates arrow head types to ArenaBox.
crates/oxc_parser/src/cursor.rs Migrates list parsing helpers to return/accept ArenaVec and arena boxes.
crates/oxc_minifier/src/traverse_context/scoping.rs Updates scope insertion API to take &ArenaVec<'a, Statement<'a>>.
crates/oxc_minifier/src/traverse_context/mod.rs Updates TraverseCtx docs and ArenaVec statement APIs.
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs Uses ArenaVec for peephole argument lists.
crates/oxc_minifier/src/peephole/replace_known_methods.rs Uses ArenaVec alias for arguments and ArenaBox for regex pattern storage.
crates/oxc_minifier/src/peephole/remove_unused_expression.rs Uses ArenaVec for argument folding outputs and return types.
crates/oxc_minifier/src/peephole/remove_dead_code.rs Uses ArenaVec for spread-argument removal API.
crates/oxc_minifier/src/peephole/normalize.rs Uses ArenaVec for statement lists in traversal hook.
crates/oxc_minifier/src/peephole/mod.rs Uses ArenaVec throughout peephole traversal entrypoints.
crates/oxc_minifier/src/peephole/minimize_statements.rs Migrates peephole minimization buffers and statement vecs to arena aliases.
crates/oxc_mangler/src/lib.rs Migrates mangler’s temp arena collections to ArenaVec/ArenaHashSet.
crates/oxc_linter/src/utils/jest/parse_jest_fn.rs Uses ArenaVec references for AST argument lists.
crates/oxc_linter/src/rules/vitest/prefer_called_exactly_once_with.rs Migrates block statement vec references to ArenaVec.
crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs Migrates object property vec references to ArenaVec.
crates/oxc_linter/src/rules/unicorn/no_unreadable_array_destructuring.rs Migrates array destructuring element vec type to ArenaVec.
crates/oxc_linter/src/rules/unicorn/no_invalid_fetch_options.rs Migrates object expression box type to ArenaBox.
crates/oxc_linter/src/rules/typescript/prefer_function_type.rs Simplifies body binding while relying on ArenaVec typing.
crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs Migrates parameter vec references to ArenaVec.
crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs Migrates statement vec references to ArenaVec.
crates/oxc_linter/src/rules/typescript/consistent_generic_constructors.rs Migrates type annotation box reference to ArenaBox.
crates/oxc_linter/src/rules/shared/jest_vitest/valid_expect_in_promise.rs Migrates statement/argument vec references to ArenaVec.
crates/oxc_linter/src/rules/shared/jest_vitest/require_hook.rs Migrates statement vec references to ArenaVec.
crates/oxc_linter/src/rules/shared/jest_vitest/no_test_return_statement.rs Migrates function body box reference to ArenaBox.
crates/oxc_linter/src/rules/react/no_danger_with_children.rs Migrates object property vec references to ArenaVec.
crates/oxc_linter/src/rules/react/jsx_no_useless_fragment.rs Migrates JSX children vec references to ArenaVec.
crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs Migrates JSX children vec references to ArenaVec.
crates/oxc_linter/src/rules/react/exhaustive_deps.rs Uses ArenaVec when constructing dependency arrays in fixes.
crates/oxc_linter/src/rules/promise/no_return_in_finally.rs Migrates function body box reference to ArenaBox.
crates/oxc_linter/src/rules/oxc/no_map_spread.rs Updates safety comment to refer to ArenaBox.
crates/oxc_linter/src/rules/import/consistent_type_specifier_style.rs Uses ArenaVec to build new import specifier lists.
crates/oxc_linter/src/rules/eslint/require_unicode_regexp.rs Migrates argument vec type to ArenaVec.
crates/oxc_linter/src/rules/eslint/prefer_object_spread.rs Migrates object expression box type to ArenaBox.
crates/oxc_linter/src/rules/eslint/no_useless_return.rs Migrates statement vec reference type to ArenaVec.
crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs Migrates argument vec reference type to ArenaVec.
crates/oxc_linter/src/rules/eslint/no_obj_calls.rs Migrates identifier reference box type to ArenaBox.
crates/oxc_linter/src/rules/eslint/grouped_accessor_pairs.rs Updates map value types to use ArenaBox with explicit lifetimes.
crates/oxc_linter/src/rules/eslint/array_callback_return/return_checker.rs Migrates statement vec reference to ArenaVec.
crates/oxc_linter/src/ast_util.rs Migrates regex flag extractor to accept ArenaVec.
crates/oxc_formatter/src/print/variable_declaration.rs Migrates AstNode<Vec<...>> formatting impl to ArenaVec.
crates/oxc_formatter/src/print/union_type.rs Migrates union list formatting to ArenaVec and updates comment.
crates/oxc_formatter/src/print/type_parameters.rs Migrates type parameter list formatting to ArenaVec.
crates/oxc_formatter/src/print/tuple_type.rs Migrates tuple element list formatting to ArenaVec.
crates/oxc_formatter/src/print/template/mod.rs Migrates template printing string building to ArenaStringBuilder.
crates/oxc_formatter/src/print/template/embed/markdown.rs Migrates markdown embed string building to ArenaStringBuilder.
crates/oxc_formatter/src/print/template/embed/html.rs Migrates html embed string building to ArenaStringBuilder.
crates/oxc_formatter/src/print/template/embed/css.rs Migrates css embed string building to ArenaStringBuilder.
crates/oxc_formatter/src/print/switch_statement.rs Migrates switch case list formatting to ArenaVec.
crates/oxc_formatter/src/print/program.rs Migrates program directive/statement list formatting to ArenaVec.
crates/oxc_formatter/src/print/mod.rs Migrates multiple list-formatting impls to ArenaVec.
crates/oxc_formatter/src/print/jsx/mod.rs Migrates JSX attribute list formatting to ArenaVec.
crates/oxc_formatter/src/print/jsx/element.rs Migrates JSX children list formatting to ArenaVec.
crates/oxc_formatter/src/print/intersection_type.rs Migrates intersection list formatting to ArenaVec.
crates/oxc_formatter/src/print/import_declaration.rs Migrates import specifier/attribute list formatting to ArenaVec.
crates/oxc_formatter/src/print/export_declarations.rs Migrates export specifier list formatting to ArenaVec.
crates/oxc_formatter/src/print/decorators.rs Migrates decorator list formatting to ArenaVec.
crates/oxc_formatter/src/print/class.rs Migrates class element/implements/etc formatting to ArenaVec.
crates/oxc_formatter/src/print/call_like_expression/arguments.rs Migrates call argument list formatting to ArenaVec.
crates/oxc_formatter/src/print/block_statement.rs Migrates block statement list formatting to ArenaVec.
crates/oxc_formatter/src/print/binding_property_list.rs Migrates binding property list node types to ArenaVec.
crates/oxc_formatter/src/print/assignment_pattern_property_list.rs Migrates assignment target property list node types to ArenaVec.
crates/oxc_formatter/src/print/array_element_list.rs Migrates array element list node types to ArenaVec.
crates/oxc_formatter/src/formatter/trivia.rs Migrates trivia/comment normalization to ArenaStringBuilder.
crates/oxc_formatter/src/ast_nodes/node.rs Migrates import-expression argument synthesis vec to ArenaVec.
crates/oxc_formatter/src/ast_nodes/iterator.rs Migrates AstNode<Vec<...>> iterator impls to AstNode<ArenaVec<...>>.
crates/oxc_formatter_json/src/comments.rs Migrates JSON comment normalization to ArenaStringBuilder.
crates/oxc_ecmascript/src/constant_evaluation/call_expr.rs Migrates constant-eval helpers to accept ArenaVec argument lists.
crates/oxc_ast/src/ast_builder_impl.rs Migrates AstBuilder APIs to return ArenaBox/ArenaVec.
apps/oxfmt/src/prettier_compat/from_prettier_doc.rs Migrates doc conversion string building to ArenaStringBuilder.

Comment thread crates/oxc_formatter/src/print/call_like_expression/arguments.rs Outdated
Comment thread crates/oxc_traverse/src/context/mod.rs Outdated
Comment thread crates/oxc_minifier/src/traverse_context/mod.rs Outdated
Comment thread crates/oxc_span/src/cmp.rs Outdated
@overlookmotel overlookmotel force-pushed the om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_ branch from 4b2595a to 2ea7dcc Compare June 23, 2026 20:30
@graphite-app graphite-app Bot added the 0-merge Merge with Graphite Merge Queue label Jun 24, 2026
@graphite-app

graphite-app Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Merge activity

#23747)

Pure refactor.

Use `ArenaBox` and `ArenaVec` everywhere for the arena-allocated types from `oxc_allocator`, instead of plain `Box` and `Vec`.

This disambiguates when `Vec` is `oxc_allocator::Vec` and when it's `std::vec::Vec`, making code clearer to follow.

Previously it was easy to confuse the two, and such confusion led to UB in `Traverse` (fixed in #23745).

Ditto other arena types - `ArenaHashMap`, `ArenaHashSet`, `ArenaStringBuilder`.

The only exceptions are:

1. Inside `oxc_allocator` crate itself.
2. AST type definitions.
3. Generated code (migrated separately in #23749).
@graphite-app graphite-app Bot force-pushed the om/06-23-refactor_allocator_export_arenabox_and_arenavec_aliases branch from 3f1e6c5 to 8c6481b Compare June 24, 2026 01:21
@graphite-app graphite-app Bot force-pushed the om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_ branch from 2ea7dcc to d1f18cd Compare June 24, 2026 01:22
graphite-app Bot pushed a commit that referenced this pull request Jun 24, 2026
Pure refactor.

#23747 changed all usage of `Vec` and `Box` to `ArenaVec` / `ArenaBox` in hand-written code. Do the same for generated code.
Base automatically changed from om/06-23-refactor_allocator_export_arenabox_and_arenavec_aliases to main June 24, 2026 01:26
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jun 24, 2026
@graphite-app graphite-app Bot merged commit d1f18cd into main Jun 24, 2026
32 checks passed
@graphite-app graphite-app Bot deleted the om/06-23-refactor_all_import_arena_box_and_vec_as_arenabox___arenavec_ branch June 24, 2026 01:27
camc314 pushed a commit that referenced this pull request Jul 3, 2026
#23747)

Pure refactor.

Use `ArenaBox` and `ArenaVec` everywhere for the arena-allocated types from `oxc_allocator`, instead of plain `Box` and `Vec`.

This disambiguates when `Vec` is `oxc_allocator::Vec` and when it's `std::vec::Vec`, making code clearer to follow.

Previously it was easy to confuse the two, and such confusion led to UB in `Traverse` (fixed in #23745).

Ditto other arena types - `ArenaHashMap`, `ArenaHashSet`, `ArenaStringBuilder`.

The only exceptions are:

1. Inside `oxc_allocator` crate itself.
2. AST type definitions.
3. Generated code (migrated separately in #23749).
camc314 pushed a commit that referenced this pull request Jul 3, 2026
Pure refactor.

#23747 changed all usage of `Vec` and `Box` to `ArenaVec` / `ArenaBox` in hand-written code. Do the same for generated code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-ast-tools Area - AST tools A-cli Area - CLI A-formatter Area - Formatter A-linter Area - Linter A-minifier Area - Minifier A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants