Skip to content

Can't refer to enum variant via Self keyword #44299

Closed
@TheDan64

Description

@TheDan64

Since this works:

match *self {
    MyEnum::Variant1 => (),
    MyEnum::Variant2 => (),
}

I expected this to work, when in the context of that enum's implementation:

match *self {
    Self::Variant1 => (),
    Self::Variant2 => (),
}

but instead you get the error: error[E0599]: no associated item named `Variant1` found for type `MyEnum` in the current scope which seems to suggest the compiler is indeed looking at MyEnum but is one step away from making the association.

Playpen link

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