fix(rust): box an optional of the struct itself (+3) - #3376
Merged
Conversation
gHashTag
enabled auto-merge (squash)
September 6, 2026 07:45
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
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.
Closes #3375
A struct holding an OPTIONAL of itself is infinitely sized in Rust:
Zig writes
?KDNodeand stores it inline, because its optional of a struct is a tagged union of known size. Rust needs the indirection spelled out, and rustc says so and names the repair.Only
Option<ThisStruct>is rewritten, and only on an exact name match.Vec<ThisStruct>is already indirect and is left alone; a bareThisStructwould still be infinite but does not occur in the corpus, and guessing at a shape nothing exhibits is how a rule outgrows its evidence.Measured: 357 → 360, zero regressions —
kd_tree,octree,quadtree.Worth naming:
octree.t27was recorded as a regression in #3247, where I wrote that[8]?OctNodeis "genuinely infinitely sized". That was true of the emitted Rust and not of the spec. It is no longer a regression, and the note that claimed it is now wrong.Boundary control, four cases in one probe:
?NodeinsideNodeOption<Box<Node>>?OtherOption<Other>— untouched?NodeExtraOption<NodeExtra>— an exact match does not catch a prefix[]NodeVec<Node>— untouched