Skip to content

Better error message for incorrect struct construction syntax. #12425

Closed
@dylanbraithwaite

Description

@dylanbraithwaite

If a type parametrized struct is constructed with the parameter in the type name, the error produced is not relevant to the actual problem:

struct MyStruct<T> { my_field : T}

followed by:

let struct_instance = MyStruct<int> { my_field : 42}

Will produce the error:

error: expected one of `;`, `}` but found `:`
    let struct_instance = MyStruct<int>{my_field : 42};
                                                 ^

Which does not indicate that the error is due to the inclusion of '<int>' after the struct's name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions