Skip to content

rustc infinite loop on recursive type (FingerTree, indirectly polymorphic/nonregular)  #52852

Open
@pnkfelix

Description

@pnkfelix

Spawned off of #4363, specifically the example provided by @goffrie

This example code causes rustc to infinite loop (playground):

enum FingerTree<A> {
    Empty,
    Single(A),
    Deep(Node<A>)
}

struct Node<A> {
    count: i32,
    front: Digit<A>,
    inner: Box<FingerTree<(A,A)>>,
    back: Digit<A>
}

struct Digit<A> {
    count: i32,
    content: [Option<A>; 4]
}

fn FingerTree<A>() -> FingerTree<A> { FingerTree::Empty }

fn main() {
    let _ = FingerTree::Deep(Node { count: 0,
        front: Digit { count: 0, content: [None, None, None, None] },
        inner: Box::new(FingerTree::Single((1, 2))),
        back: Digit { count: 0, content: [None, None, None, None] }}
    );
}

Metadata

Metadata

Assignees

Labels

I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium 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