Skip to content

fix(rust): a field that names its own struct needs a Box (+3) - #3378

Closed
gHashTag wants to merge 1 commit into
masterfrom
recursive-needs-a-box
Closed

fix(rust): a field that names its own struct needs a Box (+3)#3378
gHashTag wants to merge 1 commit into
masterfrom
recursive-needs-a-box

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Closes #3377

Chosen with tri one-away, not guessed. It reported recursive type X has infinite size as the sole error of 3 specs whose count is exact; the repair moved exactly those 3. First fix in five passes to move the column.

pub const KDNode = struct { left : "?KDNode", ... }
  ->  pub left: Option<KDNode>          inside  pub struct KDNode
rustc: recursive type `KDNode` has infinite size ... insert some indirection

There is no version of this that compiles without indirection, so nothing is being chosen about representation — it is the difference between output and no output. Box is the ownership-preserving one of the three names rustc offers.

Two shapes, and the second corrects a claim of mine. Option<Name> is kd_tree. [Option<Name>; N] is octree and quadtree — and an earlier pass of mine wrote octree.t27 off as "genuinely infinitely sized". It is not: an array is inline storage, only the element needs the box, and [Option<Box<OctNode>>; 8] is finite.

Measured, two pinned binaries built from the same commit in one pass, 650 specs: 357 → 360, +3, zero regressions.

Nine structs in the corpus name themselves; three were one-away and are now green. Narrow on purpose: Vec<Name> already carries its indirection and is untouched, and a shape this does not recognise keeps its current output rather than getting a guess.

@gHashTag

gHashTag commented Sep 6, 2026

Copy link
Copy Markdown
Owner Author

Duplicate: master already emits Option<Box<KDNode>> and [Option<Box<OctNode>>; 8], and all three tree specs compile there. A neighbour session landed the same repair, both shapes, while this branch was being measured.

The measurement stands and is worth recording: tri one-away named exactly these 3 specs as one repair from compiling, and the repair moved exactly 3 — 357 → 360, zero regressions. That the prediction matched the result is the check on the method, whichever branch shipped it.

Not caught by tri loop claim: I claimed rust-exact-one-away before starting, but a claim only separates two sessions when both take one.

@gHashTag gHashTag closed this Sep 6, 2026
auto-merge was automatically disabled September 6, 2026 08:08

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A field that names its own struct needs a Box, and three tree specs are one repair from compiling

1 participant