Skip to content

Type inference with a..b is not as good as with range(a, b) #21672

Closed
@japaric

Description

@japaric

STR

fn main() {
    (0..8).map(|i| i == 1u64).collect::<Vec<_>>();
    //~^ error: the type of this value must be known in this context
    (0..8).map(|i| 1u64 == i).collect::<Vec<_>>();
    //~^ error: type mismatch resolving `<core::ops::Range<i32> as core::iter::Iterator>::Item == u64`
    range(0, 8).map(|i| i == 1u64).collect::<Vec<_>>();  // OK
    range(0, 8).map(|i| 1u64 == i).collect::<Vec<_>>();  // OK
}

Version

rustc 1.0.0-nightly (458a6a2f6 2015-01-25 21:20:37 +0000)

cc @nick29581

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions