Skip to content

Weird compiler reporting when for is forgotten #8128

Closed
@Seldaek

Description

@Seldaek

I don't know if it's fixable, but it would be nice if the ... || {} syntax created an error when it doesn't make sense (or does it and I am confused?)

To reproduce, try to compile:

fn main() {
    let test = [0, 1];
    test.iter().advance |val| {
        println(arg);
    }
}

As you see for is missing at line 3, but the compiler reports:

test.rs:3:25: 3:28 error: unresolved name `val`. Did you mean `test`?
test.rs:3     test.iter().advance |val| {
                                   ^~~
test.rs:4:16: 4:19 error: unresolved name `arg`. Did you mean `test`?
test.rs:4         println(arg);
                          ^~~

Which is very misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions