Skip to content

reached the recursion limit during monomorphization (selection ambiguity) #262

Closed
@weiznich

Description

@weiznich

Compiling some futures related code fails with:
error: reached the recursion limit during monomorphization (selection ambiguity)

extern crate futures; // 0.1.6
extern crate futures_cpupool; // 0.1.2

use futures::Future;
use futures_cpupool::CpuPool;

const MAX: usize = 10;

fn work(n: u32) -> Result<u32, ()> {
    ::std::thread::sleep_ms(n * 2);
    Ok(n)
}

fn fold_b(a: u64, b: u32) -> u64 {
    ::std::thread::sleep_ms(b);
    a + b as u64
}

fn main() {
    let pool = CpuPool::new_num_cpus();
    let data = (0..MAX).rev().collect::<Vec<_>>();
    let a = {
        let workers = data.clone()
            .into_iter()
            .map(|d| pool.spawn_fn(move || work(d as u32)));
        ::futures::collect(workers).wait().unwrap().into_iter().fold(0, fold_b)
    };
}

rustc --version rustc 1.15.0-nightly (d9bdc636d 2016-11-24)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions