Skip to content

refactor(ast_tools): remove kind from EnumDef#21684

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

refactor(ast_tools): remove kind from EnumDef#21684
graphite-app[bot] merged 1 commit intomainfrom
om/02-14-refactor_ast_tools_remove_kind_from_enumdef_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 23, 2026

It's been the case for a while that only structs have AstKinds, never enums. So:

  1. Remove kind field from EnumDef - it's always Kind { has_kind: false }.
  2. Simplify generators which had code to handle enums which have an AstKind. It's dead code, as none do.

Does not alter generated code, only simplifies the means by which it's produced.

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:06
Copilot AI review requested due to automatic review settings April 23, 2026 14:06
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

Removes the unused kind extension from EnumDef (enums never have AstKind) and simplifies generators by deleting now-dead enum-kind branches, without changing generated output.

Changes:

  • Remove kind: Kind from EnumDef and its initialization/imports.
  • Simplify visitor and formatter generators by hardcoding “no kind” behavior for enums.
  • Simplify formatter AstNodes generation to consider only structs for AstKind-backed node variants.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/ast_tools/src/schema/extensions/kind.rs Update Kind docs to reflect struct-only usage.
tasks/ast_tools/src/schema/defs/enum.rs Remove kind field from EnumDef and constructor init.
tasks/ast_tools/src/generators/visit.rs Drop enum has_kind handling; always generate enter/leave-node hooks as “no kind” for enums.
tasks/ast_tools/src/generators/formatter/format.rs Remove dead enum-kind parent allocation path; always use self.parent for enums.
tasks/ast_tools/src/generators/formatter/ast_nodes.rs Remove enum-kind paths from AstNodes name collection, span handling, and enum impl generation helpers.

@overlookmotel overlookmotel requested a review from Dunqing April 23, 2026 14:16
@overlookmotel
Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 23, 2026

@Dunqing I'm planning to merge this without waiting for your review, as it doesn't alter any generated code. But just pinging you since it makes changes in your area (formatter).

@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-docs_ast_tools_correct_doc_comment_for_astkind_codegen branch from 977d89e to 2fba253 Compare April 23, 2026 15:39
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
It's been the case for a while that only structs have `AstKind`s, never enums. So:

1. Remove `kind` field from `EnumDef` - it's always `Kind { has_kind: false }`.
2. Simplify generators which had code to handle enums which have an `AstKind`. It's dead code, as none do.

Does not alter generated code, only simplifies the means by which it's produced.
@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 graphite-app Bot force-pushed the om/02-14-docs_ast_tools_correct_doc_comment_for_astkind_codegen branch from 2fba253 to 8937d6b Compare April 23, 2026 15:49
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
It's been the case for a while that only structs have `AstKind`s, never enums. So:

1. Remove `kind` field from `EnumDef` - it's always `Kind { has_kind: false }`.
2. Simplify generators which had code to handle enums which have an `AstKind`. It's dead code, as none do.

Does not alter generated code, only simplifies the means by which it's produced.
@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 graphite-app Bot force-pushed the om/02-14-docs_ast_tools_correct_doc_comment_for_astkind_codegen branch from 8937d6b to c5d23e4 Compare April 23, 2026 17:23
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
It's been the case for a while that only structs have `AstKind`s, never enums. So:

1. Remove `kind` field from `EnumDef` - it's always `Kind { has_kind: false }`.
2. Simplify generators which had code to handle enums which have an `AstKind`. It's dead code, as none do.

Does not alter generated code, only simplifies the means by which it's produced.
@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
It's been the case for a while that only structs have `AstKind`s, never enums. So:

1. Remove `kind` field from `EnumDef` - it's always `Kind { has_kind: false }`.
2. Simplify generators which had code to handle enums which have an `AstKind`. It's dead code, as none do.

Does not alter generated code, only simplifies the means by which it's produced.
@graphite-app graphite-app Bot force-pushed the om/02-14-docs_ast_tools_correct_doc_comment_for_astkind_codegen branch from c5d23e4 to 7c960d9 Compare April 23, 2026 17:32
@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
Base automatically changed from om/02-14-docs_ast_tools_correct_doc_comment_for_astkind_codegen to main April 23, 2026 18:47
@graphite-app graphite-app Bot merged commit 1c50067 into main Apr 23, 2026
26 checks passed
@graphite-app graphite-app Bot deleted the om/02-14-refactor_ast_tools_remove_kind_from_enumdef_ branch April 23, 2026 18:48
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