Skip to content

refactor(ast_tools): simplify AstKind generator#21685

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-14-refactor_ast_tools_simplify_astkind_generator
Apr 23, 2026
Merged

refactor(ast_tools): simplify AstKind generator#21685
graphite-app[bot] merged 1 commit intomainfrom
om/02-14-refactor_ast_tools_simplify_astkind_generator

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented 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.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 23, 2026


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.

@overlookmotel overlookmotel self-assigned this Apr 23, 2026
@overlookmotel overlookmotel added A-ast-tools Area - AST tools C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Apr 23, 2026 — with Graphite App
@overlookmotel overlookmotel marked this pull request as ready for review April 23, 2026 14:12
Copilot AI review requested due to automatic review settings April 23, 2026 14:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::prepare to mark has_kind based on the presence of a node_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_mut to 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.

Comment thread tasks/ast_tools/src/generators/ast_kind.rs
@overlookmotel overlookmotel force-pushed the om/02-14-refactor_ast_tools_simplify_astkind_generator branch from 7dad5a9 to 8b1e928 Compare April 23, 2026 14:24
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 23, 2026

Merge activity

@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ branch from cf1e835 to 4bfbe8f Compare April 23, 2026 15:40
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.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_simplify_astkind_generator branch from 8b1e928 to bcd1161 Compare April 23, 2026 15:40
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ branch from 4bfbe8f to 7dfdfdb Compare April 23, 2026 15:50
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.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_simplify_astkind_generator branch from bcd1161 to 6b1d7f2 Compare April 23, 2026 15:50
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ branch from 7dfdfdb to 3ca13a1 Compare April 23, 2026 17:24
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.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_simplify_astkind_generator branch from 6b1d7f2 to d0f8e10 Compare April 23, 2026 17:24
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.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ branch from 3ca13a1 to 1c50067 Compare April 23, 2026 17:32
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_tools_simplify_astkind_generator branch from d0f8e10 to 8e421a3 Compare April 23, 2026 17:33
Base automatically changed from om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ to main April 23, 2026 18:48
@graphite-app graphite-app Bot merged commit 8e421a3 into main Apr 23, 2026
26 checks passed
@graphite-app graphite-app Bot deleted the om/02-14-refactor_ast_tools_simplify_astkind_generator branch April 23, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants