Skip to content

Confusing error message for incorrect struct variant field #19922

Closed
@tomjakubowski

Description

@tomjakubowski
enum Foo {
    Bar { x: () }
}

fn main() {
    let f = Foo::Bar { y: () };
}

Produces:

<anon>:6:24: 6:25 error: structure `Foo` has no field named `y`
<anon>:6     let f = Foo::Bar { y: () };
                                ^
error: aborting due to previous error
playpen: application terminated with error code 101

It would be more helpful to say that the struct variant Foo::Bar has no field named y.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions