Add inline-union support and complete pdaSeed generation#94
Merged
Conversation
This was referenced Jun 10, 2026
Member
Author
This was referenced Jun 10, 2026
Merged
Member
Author
Merge activity
|
This PR introduces an `INLINE_UNIONS` allowlist in the generator so that unions without a `registered<Name>` twin can be emitted on an opt-in basis, with a per-union `stripSuffix` controlling variant naming. The infrastructure is validated end to end by completing `pdaSeed`, which was deliberately left out of the previous PR pending exactly this machinery. The `pdaSeed` category now joins `count`, `discriminator`, and `link` under `CATEGORY_ROUTING`, and `codama-nodes/src/generated/pda_seed_nodes/` gains five files: per-node `constant_pda_seed_node.rs` and `variable_pda_seed_node.rs`, the inline-union `constant_pda_seed_value.rs`, the category-union `pda_seed_node.rs`, and a `mod.rs`. The hand-written `pda_seed_nodes/*.rs` files shrink to constructors and `#[cfg(test)] mod tests` blocks, mirroring the PR #1/#2 treatment of link and count/discriminator nodes. One bespoke `impl From<ValueNode> for ConstantPdaSeedValue` is added to the hand-written `constant_pda_seed_node.rs` to bridge the broader `ValueNode` enum into the new `ConstantPdaSeedValue` superset that includes `ProgramId(ProgramIdValueNode)`. The `ConstantPdaSeedNode.value` field type changes from `ValueNode` to `ConstantPdaSeedValue`; existing call sites that pass leaf value nodes work via the auto-derived `From<Variant>` impls, and the one caller in `codama-korok-visitors/src/set_pdas_visitor.rs` that passes a resolved `ValueNode` flows through the new bridge. Also lands the box-all-union heuristic: every direct (non-Vec) field whose type is a union is wrapped in `Box<\u2026>` (required \u2192 `Box<T>`; optional \u2192 `Box<Option<T>>`, box outside Option). This keeps every category-union variant pointer-sized for its union fields, which is what `clippy::large_enum_variant` actually cares about. The newly-generated pdaSeed structs box their `type` and `value` union fields accordingly; the hand-written constructors wrap with `Box::new(...)` and the corresponding tests dereference with `*node.r#type` / `*node.value`.
52c15da to
b91a31c
Compare
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.

This PR introduces an
INLINE_UNIONSallowlist in the generator so that unions without aregistered<Name>twin can be emitted on an opt-in basis, with a per-unionstripSuffixcontrolling variant naming. The infrastructure is validated end to end by completingpdaSeed, which was deliberately left out of the previous PR pending exactly this machinery. ThepdaSeedcategory now joinscount,discriminator, andlinkunderCATEGORY_ROUTING, andcodama-nodes/src/generated/pda_seed_nodes/gains five files: per-nodeconstant_pda_seed_node.rsandvariable_pda_seed_node.rs, the inline-unionconstant_pda_seed_value.rs, the category-unionpda_seed_node.rs, and amod.rs. The hand-writtenpda_seed_nodes/*.rsfiles shrink to constructors and#[cfg(test)] mod testsblocks, mirroring the PR #1/#2 treatment of link and count/discriminator nodes. One bespokeimpl From<ValueNode> for ConstantPdaSeedValueis added to the hand-writtenconstant_pda_seed_node.rsto bridge the broaderValueNodeenum into the newConstantPdaSeedValuesuperset that includesProgramId(ProgramIdValueNode). TheConstantPdaSeedNode.valuefield type changes fromValueNodetoConstantPdaSeedValue; existing call sites that pass leaf value nodes work via the auto-derivedFrom<Variant>impls, and the one caller incodama-korok-visitors/src/set_pdas_visitor.rsthat passes a resolvedValueNodeflows through the new bridge.Also lands the box-all-union heuristic: every direct (non-Vec) field whose type is a union is wrapped in
Box<\u2026>(required \u2192Box<T>; optional \u2192Box<Option<T>>, box outside Option). This keeps every category-union variant pointer-sized for its union fields, which is whatclippy::large_enum_variantactually cares about. The newly-generated pdaSeed structs box theirtypeandvalueunion fields accordingly; the hand-written constructors wrap withBox::new(...)and the corresponding tests dereference with*node.r#type/*node.value.