Skip to content

Regression in type inference from Iterator.sum #25094

Closed
@untitaker

Description

@untitaker

The following used to work (around the time where AdditiveIterator still existed):

fn main() {
    let content = vec!["a","aa","aaa","aaaa"];
    let lens = content.iter().map(|x| x.len());
    println!("{}", lens.sum());
}

http://is.gd/2jQlp7

The error message:

<anon>:4:25: 4:30 error: unable to infer enough type information about `_`; type annotations required [E0282]
<anon>:4     println!("{}", lens.sum());
                                 ^~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions