Skip to content

"Expected [type error]" when matching against a typo'd vector #5100

Closed
@huonw

Description

@huonw

Given tuple-type-error.rs:

fn main() {
    let v = [(1, 2)   // missing comma!
             (3, 4),
             (5, 6)];

    for v.each |&(x,y)| {}
}

rustc spits out

tuple-type-error.rs:2:13: 3:20 error: expected function or foreign function but found `(<VI0>,<VI1>)`
tuple-type-error.rs:2     let v = [(1, 2)   // missing comma!
tuple-type-error.rs:3              (3, 4),
tuple-type-error.rs:6:17: 6:22 error: mismatched types: expected `[type error]`, found tuple
tuple-type-error.rs:6     for v.each |&(x,y)| {}
                                       ^~~~~

I'm not sure if this is a bug or what, but expecting a type error seems peculiar (also, the error message for (a, b) (c, d) without a comma in a vector could be more explanatory, given it is almost certainly a typo).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions