Skip to content

Misleading compiler hint for wrong keyword constructor syntax #57684

Description

@vektordev

The following code

struct MyClass{
    pub field:i32,
}

fn main(){
    let myClass = MyClass{field=5};
}

produces the following error message:

error: expected one of `,` or `}`, found `=`

This code errors because "field=5" should be "field:5". The error message leads any good python programmer astray. I think the error message should at least mention the possibility of :.

This probably belongs in A-diagnostics

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions