Skip to content

"error: reached the recursion limit during monomorphization" with unboxed closures #19596

Closed
@japaric

Description

@japaric

Came up with this issue while "unboxing" the collections::trie::map::InternalNode::each_reverse method.

Reduced test case

#![feature(unboxed_closures)]

struct Struct;

impl Struct {
    fn method_ok(&self, f: |()| -> bool) -> bool {
        self.method_ok(|t| f(t))
    }

    fn method_bad<F>(&self, f: F) -> bool where F: Fn(()) -> bool {
        self.method_bad(|t| f(t))
    }

    fn method_bad2<F>(&self, f: F) -> bool where F: Fn(()) -> bool {
        let f: &Fn(()) -> bool = &f;

        self.method_bad2(|t| f.call((t,)))
    }
}

fn main() {
    Struct.method_ok(|_| true);
    // Pick one
    Struct.method_bad(|_| true);
    //Struct.method_bad2(|_| true);
}

Output

limit.rs:10:5: 12:6 error: reached the recursion limit during monomorphization
limit.rs:10     fn method_bad<F>(&self, f: F) -> bool where F: Fn(()) -> bool {
limit.rs:11         self.method_bad(|t| f(t))
limit.rs:12     }

Version

rustc 0.13.0-dev (d9c7c00b9 2014-12-04 21:33:07 +0000)

cc @nikomatsakis (you already know, but I want to keep track of the issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions