E1044: type contains itself without indirection

View source

A struct or an enum cannot contain a value of its own type, directly or through other types, because its size would be infinite.

A struct or an enum cannot contain a value of its own type, directly or through other types, because its size would be infinite. ADR-0046 allows a recursive definition only when it stays finite, for example through Option. The message names a type of the cycle, and the error points at the start of that declaration.

Example

actus
struct Node {
    next: Node,
}

verb main() {
}

Fix

Put the recursive field behind an Option.

actus
struct Node {
    next: Option[Node],
}

verb main() {
}

Run actus explain E1044 in your terminal to read this entry offline. Browse Ownership & types or all error codes.