Skip to content

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

@conradev

Description

@conradev

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 😮

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