Skip to content

Self::EnumVariant not considered const fn #64247

Closed
@marmistrz

Description

@marmistrz

When using Self to create an enum variant in Rust 1.37+, we get an error:

const VAL: Self = Self::X(42);

results in:

error: `Foo::X` is not yet stable as a const fn

but if the enum is constructed explicitly, the compilation succeeds:

const VAL: Self = Foo::X(42)

Looking at #53555, it looks like Self::EnumVariant should be considered a const fn with min_const_fn.

Playground links for both variants: error, no-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions