Skip to content

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

Description

@gHashTag

Chosen with tri one-away, which reported recursive type X has infinite size as the sole error of 3 specs whose count is exact. The repair moved exactly those 3 — the first time a fix has moved the column in five passes, and the first time the target was picked rather than guessed.

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 the kd_tree case. [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, so only the element needs the box, and [Option<Box<OctNode>>; 8] is finite.

Measured, two pinned binaries 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. Deliberately narrow: Vec<Name> already carries its indirection and is untouched, and anything more deeply nested keeps its current output rather than getting a guess.

Boundary

  • specs/tri/trees/octree.t27

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions