refactor(all): pass [] for empty ArenaVec args to AST builder methods#24622
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
60d1e75 to
25e0cac
Compare
2d01371 to
25a9811
Compare
There was a problem hiding this comment.
Pull request overview
Refactors call sites across the codebase to use the new AST builder ergonomics introduced in #24621 by passing [] for empty ArenaVec parameters, reducing boilerplate without changing behavior.
Changes:
- Replaces inline
ArenaVec::new_in(...)empty arguments with[]for AST builder methods that now accept arrays viaIntoIn. - Applies the same mechanical shortening in parser, transformer, minifier, isolated declarations, codegen tests, and React compiler code.
- Cleans up an unused
ArenaVecimport where it became unnecessary.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_transformer/src/utils/ast_builder.rs | Use [] for empty params/args/directives when building AST nodes. |
| crates/oxc_transformer/src/typescript/namespace.rs | Use [] for empty object literal properties. |
| crates/oxc_transformer/src/typescript/enum.rs | Use [] for empty decorators/properties/args in enum transform output. |
| crates/oxc_transformer/src/typescript/class.rs | Use [] for empty decorators on generated class elements. |
| crates/oxc_transformer/src/typescript/annotations.rs | Use [] for empty export specifiers and empty block statements. |
| crates/oxc_transformer/src/plugins/styled_components.rs | Update test helper call to pass [] for empty vec arg. |
| crates/oxc_transformer/src/jsx/refresh.rs | Use [] for placeholder/empty vecs in generated refresh AST. |
| crates/oxc_transformer/src/es2026/explicit_resource_management.rs | Use [] for empty call arguments in generated code. |
| crates/oxc_transformer/src/es2022/class_static_block.rs | Use [] for empty decorators and drop unused ArenaVec import. |
| crates/oxc_transformer/src/es2022/class_properties/constructor.rs | Use [] for empty params/decorators/directives in generated functions. |
| crates/oxc_transformer/src/es2022/class_properties/class.rs | Use [] for empty new expression argument lists. |
| crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs | Use [] for empty decorators and empty call args. |
| crates/oxc_transformer/src/es2018/object_rest_spread.rs | Use [] for empty object props, binding patterns, and template expressions. |
| crates/oxc_transformer/src/es2018/async_generator_functions/for_await.rs | Use [] for empty call arguments. |
| crates/oxc_transformer/src/es2017/async_to_generator.rs | Use [] for empty directives/call args in wrapper function generation. |
| crates/oxc_transformer/src/decorator/legacy/mod.rs | Use [] for empty decorators/template literal expressions. |
| crates/oxc_transformer/src/common/duplicate.rs | Use [] for empty template literal expressions vec. |
| crates/oxc_transformer/src/common/arrow_function_converter.rs | Use [] for empty decorators and function body directives. |
| crates/oxc_transformer_plugins/src/module_runner_transform.rs | Use [] for empty params and empty directives in generated function. |
| crates/oxc_react_compiler/src/react_compiler/entrypoint/program.rs | Use [] for empty export specifiers / call args. |
| crates/oxc_react_compiler/src/react_compiler_reactive_scopes/codegen_reactive_function.rs | Use [] for empty decorators/rest metadata/call args/directives. |
| crates/oxc_parser/src/lib.rs | Pass [] for program comments placeholder (still populated later). |
| crates/oxc_parser/src/js/module.rs | Use [] for empty export specifiers. |
| crates/oxc_parser/src/js/arrow.rs | Use [] for empty arrow function body directives. |
| crates/oxc_minifier/tests/ecmascript/to_string.rs | Use [] for empty object literal properties in tests. |
| crates/oxc_minifier/tests/ecmascript/to_number.rs | Use [] for empty object literal properties in tests. |
| crates/oxc_minifier/tests/ecmascript/array_join.rs | Use [] for empty object literal properties in tests. |
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Use [] for empty object/array literal elements in substitutions. |
| crates/oxc_minifier/src/peephole/remove_dead_code.rs | Use [] for empty block statement body. |
| crates/oxc_isolated_declarations/src/module.rs | Use [] for empty export specifiers. |
| crates/oxc_isolated_declarations/src/lib.rs | Use [] for empty directives/specifiers when building new programs/exports. |
| crates/oxc_isolated_declarations/src/function.rs | Use [] for empty parameter decorators. |
| crates/oxc_isolated_declarations/src/declaration.rs | Use [] for empty TS module block body metadata vec. |
| crates/oxc_isolated_declarations/src/class.rs | Use [] for empty decorators and empty signature params decorators. |
| crates/oxc_codegen/tests/integration/js.rs | Use [] for empty template expressions and empty program comments/directives. |
| crates/oxc_ast/src/builder/custom.rs | Use [] for empty decorators/specifiers in custom builder helpers. |
| crates/oxc_ast_visit/src/utf8_to_utf16/mod.rs | Use [] for empty directives in test program construction. |
|
@camc314 @Dunqing I'm going to merge this stack without review as I think it's uncontroversial and it touches a lot of files, so I want to get it in before it accrues merge conflicts. Just tagging you both so you're aware we can now use this shorter syntax when the
|
Merge activity
|
…hods (#24622) Pure refactor. Just shorten code. #24621 made AST builder methods take arrays as params. Replace `ArenaVec::new_in(...)` arguments written inline at AST builder method call sites with the empty array literal `[]`. ```rs let block = Statement::new_block_statement(SPAN, ArenaVec::new_in(ctx), ctx); ``` \-> ```rs let block = Statement::new_block_statement(SPAN, [], ctx); ```
…#24621) Builds on #24620. Make generated and hand-written AST builder methods take `impl IntoIn<'a, ArenaVec<'a, T>>` instead of `ArenaVec<'a, T>` for their `Vec` params, so callers can pass an array literal (e.g. `[]` or `[a, b]`) in place of building an `ArenaVec` explicitly. This enables shortening code in a lot of places - #24622 and following PRs.
25a9811 to
77230c5
Compare
25e0cac to
c1a074c
Compare

Pure refactor. Just shorten code.
#24621 made AST builder methods take arrays as params.
Replace
ArenaVec::new_in(...)arguments written inline at AST builder method call sites with the empty array literal[].->