Skip to content

Typedef'd enums cannot reference variants #31355

@KiChjang

Description

@KiChjang

The following code does not compile:

pub enum Foo {
    Bar,
    Qux,
}

pub type Alias = Foo;

fn main() {
    let baz = Alias::Bar;
}

It produces the following error message:

<anon>:9:15: 9:25 error: no associated item named `Bar` found for type `Foo` in the current scope
<anon>:9     let baz = Alias::Bar;
                       ^~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101

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