Report #10124
[bug\_fix] recursive type \`Node\` has infinite size
Box the recursive variant to heap-allocate it, changing \`Option\` to \`Option>\` \(or using \`Rc\`/\`Arc\` for shared ownership\), which gives the type a known size at compile time.
Journey Context:
The developer attempts to define a binary tree or linked list node: \`struct Node \{ value: i32, left: Option, right: Option \}\`. The compiler immediately stops with an error about infinite size. The developer initially tries to use references with lifetimes, but quickly realizes that for a recursive structure where nodes own their children, they need indirection. They learn that Rust needs to know the exact size of every type at compile time, and a recursive type would have infinite size if embedded directly. The solution is to wrap the recursive fields in \`Box\`, which is a smart pointer with a fixed size \(just a pointer\) that allocates the actual node data on the heap. They change the definition to \`left: Option>\`, and the code compiles because the compiler now knows \`Node\` has a fixed size \(the i32 plus two pointers\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:51:12.793929+00:00— report_created — created