Skip to content

overflow during drop-check on a recursive type #44933

Open
@wolfiestyle

Description

@wolfiestyle

I get a pretty strange error when trying to compile this: (playground link)

enum Stuff<T> {
    Value(T),
    Nested(Box<Stuff<Stuff<T>>>),
}

fn main() {
    let a = Stuff::Value(1);
}

output:

error[E0320]: overflow while adding drop-check rules for Stuff<i32>
 --> src/main.rs:7:9
  |
7 |     let a = Stuff::Value(1);
  |         ^
  |
  = note: overflowed on Stuff<Stuff<Stuff<Stuff<Stuff<Stuff< ...

If the type isn't used, the program compiles fine. Don't know if the type is actually representable or not, the error is misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.P-lowLow priorityT-compilerRelevant to the compiler 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