Skip to content

Improve error message for "for x in [1,2,3] {" #17574

Closed
@kmcallister

Description

@kmcallister

Beginners are often confused by the error message

error: `for` loop expression has type `[<generic integer #0>, .. 3]` which does not implement the `Iterator` trait

Perhaps if there's an iter() method we should suggest calling it. This involves hardcoding the name "iter", but only for the purposes of a hint that can be wrong sometimes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions