Skip to content

Uninhabited types in recursive types with "infinite" size #56674

@alecmocatta

Description

@alecmocatta

This enum is in theory finitely sized, though it's being detected as infinitely sized.

#![feature(never_type)]
enum Enum<T> {
    A,
    B(Enum<!>, T)
}

(Playground)

error[E0072]: recursive type `Enum` has infinite size
 --> src/lib.rs:2:1
  |
2 | enum Enum<T> {
  | ^^^^^^^^^^^^ recursive type has infinite size
3 |     A,
4 |     B(Enum<!>, T)
  |       ------- recursive without indirection
  |
  = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Enum` representable

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions