refactor(all): import arena Box and Vec as ArenaBox / ArenaVec#23747
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
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/ArenaVecconsistently.
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. |
4b2595a to
2ea7dcc
Compare
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).
3f1e6c5 to
8c6481b
Compare
2ea7dcc to
d1f18cd
Compare
Pure refactor. #23747 changed all usage of `Vec` and `Box` to `ArenaVec` / `ArenaBox` in hand-written code. Do the same for generated code.
#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).
Pure refactor. #23747 changed all usage of `Vec` and `Box` to `ArenaVec` / `ArenaBox` in hand-written code. Do the same for generated code.

Pure refactor.
Use
ArenaBoxandArenaVeceverywhere for the arena-allocated types fromoxc_allocator, instead of plainBoxandVec.This disambiguates when
Vecisoxc_allocator::Vecand when it'sstd::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:
oxc_allocatorcrate itself.ArenaBoxandArenaVecin generated code #23749).