Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
weiznich opened this issue Nov 27, 2016 · 4 comments
Closed

Comments

@weiznich
Copy link
Contributor

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)

@weiznich
Copy link
Contributor Author

It seems that this was introduced between version 0.1.3 and version 0.1.4.

@alexcrichton
Copy link
Member

I've opened rust-lang/rust#38033 to track this

@dwrensha
Copy link
Contributor

This particular instance of the error appears to have been eliminated, so I think it makes sense to close this issue.

I've found another instance of this error message and reported it as #367.

@alexcrichton
Copy link
Member

Oops forgot to close this with @dwrensha's last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants