Skip to content

"error: reached the recursion limit during monomorphization (selection ambiguity)" with chunks #393

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
conradev opened this issue Feb 19, 2017 · 5 comments

Comments

@conradev
Copy link

conradev commented Feb 19, 2017

Compiling the following code fails with:

error: reached the recursion limit during monomorphization (selection ambiguity)
extern crate futures; // 0.1.10

use futures::{stream, Stream, Future};
use futures::sync::oneshot;

fn main() {
    let (tx, rx) = oneshot::channel(); // future to fetch a collection of objects
    tx.complete((0..200).collect());

    rx.map(|l: Vec<usize>| stream::iter(l.into_iter().map(|i| Ok(i))))
        .flatten_stream()
        .chunks(50)
        .map(|i| Ok(i)) // do work with batch of objects
        .buffer_unordered(5)
        .collect();
}
rustc 1.15.0 (10893a9a3 2017-01-19)

The idea here is to batch process a bunch of objects. If I remove the chunks(50) line, the code successfully compiles 😮

@dwrensha
Copy link
Contributor

Possibly related to #367.

@conradev
Copy link
Author

Some more info:

  • This happens all the way back to 0.1.3, when Chunks was introduced.
  • I resolved the issue for now by waiting synchronously for the collection of objects, and then making the stream, removing the need for the map and flatten_stream.

@alexcrichton
Copy link
Member

I wonder if this may be a bug in the compiler? We've caught some before through this library. It'd be helpful to reduce the library to the bare bones though to see what's necessary to trigger the bug.

@alexcrichton
Copy link
Member

Ok I've reduced it at rust-lang/rust#40003

@goffrie
Copy link
Contributor

goffrie commented Oct 25, 2017

I suppose this issue can be closed now?

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

5 participants