refactor(ast_tools): simplify AstKind generator#21685
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
This was referenced Apr 23, 2026
Member
Author
This was referenced Apr 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors tasks/ast_tools’s AstKind code generator to use a simpler, schema-derived criterion for which AST structs get an AstKind, aligning it with the presence of node_id: Cell<NodeId>.
Changes:
- Switch
AstKindGenerator::prepareto markhas_kindbased on the presence of anode_id: Cell<NodeId>field (removing the visitor/blacklist approach). - Simplify generated
AstKind::{node_id,set_node_id}match arms to unconditionally call through to the underlying struct methods. - Add a lint expectation on
Schema::type_by_name_mutto avoid dead-code warnings after the refactor.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tasks/ast_tools/src/schema/mod.rs | Marks type_by_name_mut with #[expect(dead_code)] (now unused after generator refactor). |
| tasks/ast_tools/src/generators/ast_kind.rs | Updates has_kind selection logic to key off node_id: Cell<NodeId> and simplifies node_id / set_node_id generation. |
7dad5a9 to
8b1e928
Compare
Contributor
Merge activity
|
cf1e835 to
4bfbe8f
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
Simplify the criteria for when an AST struct has an `AstKind`. - Previously: Struct is visited (has `#[ast(visit)]` attr) _and_ is not in `STRUCTS_BLACK_LIST`. - Now: Struct has a `node_id: Cell<NodeId>` field. The two are equivalent - both criteria match exactly the same set of AST types, and this change does not alter generated code. The difference is just that it's simpler and clearer.
8b1e928 to
bcd1161
Compare
4bfbe8f to
7dfdfdb
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
Simplify the criteria for when an AST struct has an `AstKind`. - Previously: Struct is visited (has `#[ast(visit)]` attr) _and_ is not in `STRUCTS_BLACK_LIST`. - Now: Struct has a `node_id: Cell<NodeId>` field. The two are equivalent - both criteria match exactly the same set of AST types, and this change does not alter generated code. The difference is just that it's simpler and clearer.
bcd1161 to
6b1d7f2
Compare
7dfdfdb to
3ca13a1
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
Simplify the criteria for when an AST struct has an `AstKind`. - Previously: Struct is visited (has `#[ast(visit)]` attr) _and_ is not in `STRUCTS_BLACK_LIST`. - Now: Struct has a `node_id: Cell<NodeId>` field. The two are equivalent - both criteria match exactly the same set of AST types, and this change does not alter generated code. The difference is just that it's simpler and clearer.
6b1d7f2 to
d0f8e10
Compare
Simplify the criteria for when an AST struct has an `AstKind`. - Previously: Struct is visited (has `#[ast(visit)]` attr) _and_ is not in `STRUCTS_BLACK_LIST`. - Now: Struct has a `node_id: Cell<NodeId>` field. The two are equivalent - both criteria match exactly the same set of AST types, and this change does not alter generated code. The difference is just that it's simpler and clearer.
3ca13a1 to
1c50067
Compare
d0f8e10 to
8e421a3
Compare
Base automatically changed from
om/02-14-refactor_ast_tools_remove_kind_from_enumdef_
to
main
April 23, 2026 18:48
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.

Simplify the criteria for when an AST struct has an
AstKind.#[ast(visit)]attr) and is not inSTRUCTS_BLACK_LIST.node_id: Cell<NodeId>field.The two are equivalent - both criteria match exactly the same set of AST types, and this change does not alter generated code. The difference is just that it's simpler and clearer.