Skip to content

Creating data-less enum variant with data yields a confusing error message #28533

Closed
@nagisa

Description

@nagisa
enum Test {
    Variant,
    Variant2(&'static str)
}

fn main(){
    let y = Test::Variant2("Hello");
    let x = Test::Variant("World");
}

results in

<anon>:8:13: 8:35 error: expected function, found `Test`
<anon>:8     let x = Test::Variant("World");
                     ^~~~~~~~~~~~~~~~~~~~~~

The error should say something about variant not being able to contain any data instead.

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