refactor(ast_tools): simplify generating variants of code#17172
Merged
graphite-app[bot] merged 1 commit intomainfrom Dec 20, 2025
Merged
Conversation
Member
Author
This was referenced Dec 20, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the AST tools codegen to simplify generating multiple variants of code by introducing a generate_variants! macro, eliminating boilerplate code when creating code variants with different flag combinations.
- Introduces a new
generate_variants!macro that encapsulates the pattern of generating all permutations of code with different flags - Adds a
generate_arraymethod toVariantGeneratortrait for destructuring variants into multiple variables - Simplifies the usage in
estree_visit.rsby replacing 8 lines of boilerplate with a single macro call
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tasks/ast_tools/src/output/javascript.rs | Adds generate_array method to VariantGenerator trait and introduces generate_variants! macro with documentation |
| tasks/ast_tools/src/generators/estree_visit.rs | Refactors to use the new generate_variants! macro, replacing manual implementation and removing now-unnecessary clippy attribute |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4e99696 to
fff03fc
Compare
Contributor
Merge activity
|
Pure refactor. Simplify generating multiple variant of code in `ast_tools` codegen by providing a `generate_variants!` macro.
2cf020c to
e39deb6
Compare
fff03fc to
472c439
Compare
Base automatically changed from
om/12-19-refactor_linter_plugins_add_error_messages_to_debug_assertions
to
main
December 20, 2025 14:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Pure refactor. Simplify generating multiple variant of code in
ast_toolscodegen by providing agenerate_variants!macro.