Skip to content

Rustc builds forever due to infinite recursion error #74201

Closed
@myQwil

Description

@myQwil

I tried this code:

struct Recurse {
    recurse: Recurse
}

enum AType {
    ARecurse(Recurse),
}

struct MyStruct {
    atype: AType,
}

fn main() {
    let x = MyStruct { atype: AType::ARecurse(Recurse{}) };
}

I expected to see this happen:

error[E0072]: recursive type `Recurse` has infinite size
 --> main.rs:1:1
  |
1 | struct Recurse {
  | ^^^^^^^^^^^^^^ recursive type has infinite size
2 |     next: Recurse
  |     ------------- recursive without indirection
  |
  = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Recurse` representable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0072`.

Instead, this happened:

error[E0072]: recursive type `Recurse` has infinite size
 --> main.rs:1:1
  |
1 | struct Recurse {
  | ^^^^^^^^^^^^^^ recursive type has infinite size
2 |     next: Recurse
  |     ------------- recursive without indirection
  |
  = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Recurse` representable

Rustc never aborts. It gets stuck in compilation limbo.

Meta

rustc --version --verbose:

rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0

No backtrace summary available as compilation never ends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-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