Skip to content

feat(ast): add AST creation methods to AST types#23650

Draft
overlookmotel wants to merge 1 commit into
om/06-06-refactor_ast_add_ast_builder_cargo_featurefrom
om/06-06-feat_ast_add_ast_creation_methods_to_ast_types
Draft

feat(ast): add AST creation methods to AST types#23650
overlookmotel wants to merge 1 commit into
om/06-06-refactor_ast_add_ast_builder_cargo_featurefrom
om/06-06-feat_ast_add_ast_creation_methods_to_ast_types

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jun 19, 2026

Copy link
Copy Markdown
Member

Part of #23043.

Codegen AST builder methods on AST types, matching the methods which are generated on current AstBuidler type.

Add a single new AstBuilder type which is the simplest possible - just creates all nodes with dummy NodeIds - same as current builder does. But this PR includes the traits to add other AstBuild implementations later e.g. a builder for transformer which generates unique NodeId for each AST node.

Design is much the same as outlined in #23043 but:

  • Extra trait to reduce trait bounds in generated methods (so reducing code size and compile time).
  • Different naming for enum methods - Expression::new_null_literal not Expression::null_literal. This naming is more verbose, but clearer, and avoids clashing with existing methods e.g. ModuleExportName::identifier_name.

Note: All these methods are inlined (they need to be, to make AST nodes be constructed in arena directly, not built on stack and copied to arena). So the traits should not have any affect on binary size.

overlookmotel commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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.

@codspeed-hq

codspeed-hq Bot commented Jun 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing om/06-06-feat_ast_add_ast_creation_methods_to_ast_types (6143bb3) with om/06-06-refactor_ast_add_ast_builder_cargo_feature (0f7f1c2)

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.

@overlookmotel overlookmotel self-assigned this Jun 19, 2026
@overlookmotel overlookmotel force-pushed the om/06-06-feat_ast_add_ast_creation_methods_to_ast_types branch from 7cab202 to 6a2e997 Compare June 20, 2026 22:21
@overlookmotel overlookmotel force-pushed the om/06-06-refactor_ast_add_ast_builder_cargo_feature branch from 662766a to faeb137 Compare June 20, 2026 22:21
@overlookmotel overlookmotel force-pushed the om/06-06-feat_ast_add_ast_creation_methods_to_ast_types branch from 6a2e997 to 6143bb3 Compare June 21, 2026 00:39
@overlookmotel overlookmotel force-pushed the om/06-06-refactor_ast_add_ast_builder_cargo_feature branch from faeb137 to 0f7f1c2 Compare June 21, 2026 00:39
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant