Skip to content

Type inference regression with zipped iterators #29278

Closed
@larsluthman

Description

@larsluthman

The following code compiles with Stable and Beta but not with Nightly on https://play.rust-lang.org/ as of 2015-10-24:

fn main() {
    let mut output = vec![Vec::<i32>::new(); 5];
    let input = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
    for chunk in input.chunks(5) {
        for (i, o) in chunk.iter().zip(output.as_mut()) {
            o.push(*i);
        }
    }
    println!("{:?}", output);
}

With Stable and Beta I get the correct output:

[[0, 5, 10], [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9]]

With Nightly I get the error message

<anon>:6:13: 6:23 error: the type of this value must be known in this context
<anon>:6             o.push(*i);

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions