refactor(ast_tools): simplify struct field reordering#20587
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 20, 2026
Merged
Conversation
This was referenced Mar 20, 2026
Member
Author
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors ast_tools’ struct field reordering logic by explicitly tracking field layout order (including ZSTs), simplifying how layout assertions and #[ast] field-reorder metadata are derived without changing computed sizes/alignments.
Changes:
- Add
layout_indextoOffsetto represent deterministic memory layout order even when ZST offsets collide. - Simplify struct layout calculation by removing the “collect ZSTs then append last” path and assigning layout order during field placement.
- Update struct-details generation and assertions to sort/emit by
layout_index(reflected in regeneratedSTRUCTS, e.g.Span).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tasks/ast_tools/src/schema/extensions/layout.rs | Extends Offset with layout_index to disambiguate layout ordering when offsets aren’t unique. |
| tasks/ast_tools/src/generators/assert_layouts.rs | Assigns layout_index during layout calculation; uses it for assertion ordering and StructDetails emission. |
| crates/oxc_ast_macros/src/generated/structs.rs | Regenerated struct reorder table based on the updated layout-ordering logic. |
99eaa38 to
3a94ef2
Compare
d7bf984 to
79deba6
Compare
Member
Author
Merge activity
|
Follow-on after #20584. Simplify implementation of struct field ordering in `ast_tools`. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.
79deba6 to
89946e1
Compare
3a94ef2 to
5c385af
Compare
Base automatically changed from
om/02-15-perf_ast_mark_astkind_address_as_inline_
to
main
March 20, 2026 22:31
costajohnt
pushed a commit
to costajohnt/oxc
that referenced
this pull request
Mar 22, 2026
) Follow-on after oxc-project#20584. Simplify implementation of struct field ordering in `ast_tools`. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.
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.

Follow-on after #20584. Simplify implementation of struct field ordering in
ast_tools. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.