Skip to content

Infinite loop/stack overflow in rustc (dropck) on non-regular data type #22443

Closed
@miv-ableton

Description

@miv-ableton

The compiler goes into an infinite loop compiling this code (an incomplete finger tree implementation):

struct Digit<T> {
    elem: T,
    next: Option<Box<Digit<T>>>
}

enum Node<T> {
    Node2(T, T),
    Node3(T, T, T)
}

enum FingerTree<T> {
    Empty,
    Single(T),
    Deep(Digit<T>, Box<FingerTree<Node<T>>>, Digit<T>)
}

impl <T> FingerTree<T> {
    fn dequeue(&self, elem: T) -> FingerTree<T> {
        match self {
            Empty => FingerTree::Single(elem)
        }
    }
}

fn main() {
    let ft = FingerTree::Empty;
    let ft2 = ft.dequeue(123);
}

Tested with latest nightly. I can also cause this to happen by pasting this into the box on the rust-lang homepage.

Metadata

Metadata

Assignees

Labels

A-destructorsArea: Destructors (`Drop`, …)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions