Skip to content

mGCA: Can't specify generic args (of enum) on enum itself in unit & tuple variant constructions in (direct) const args #154915

@fmease

Description

@fmease

Everywhere else, Enum::Variant::<…> and Enum::<…>::Variant are interchangeable. In both cases the list <…> contains the generic args for the enum. This holds true for unit (E::V), tuple (E::V(…)) and true (braced) struct (E::V {…}) variant constructions.

However, in direct const args (as opposed to AnonConst const args), the Enum::<…>::Variant form is not permitted in unit & tuple constructions forcing you to specify them via Enum::Variant::<…>. Enum::<…>::Variant { … } (true struct construction) works fine on the other hand.

#![feature(min_generic_const_args)]
#![feature(adt_const_params, unsized_const_params)]

#[derive(PartialEq, Eq, std::marker::ConstParamTy)]
enum Enum<T> {
    Unit,
    Tuple(),
    Store(T),
}

// FIXME:  Ctor(Variant, Const)
type const _: Enum<()> = Enum::<()>::Unit;
//~^ ERROR type arguments are not allowed on enum `Enum`
//~| ERROR missing generics for enum `Enum`

// FIXME:  Ctor(Variant, Fn)
type const _: Enum<()> = Enum::<()>::Tuple();
//~^ ERROR type arguments are not allowed on enum `Enum`
//~| ERROR missing generics for enum `Enum`

// OK:  Variant
type const _: Enum<()> = Enum::<()>::Unit {};


type const _: Enum<()> = Enum::Unit::<()>; // OK
type const _: Enum<()> = Enum::Tuple::<()>(); // OK

type const _: Enum<()> = const { Enum::<()>::Unit }; // (OK)
type const _: Enum<()> = const { Enum::<()>::Tuple() }; // (OK)

Metadata

Metadata

Assignees

Labels

A-HIR-ty-loweringArea: HIR ty lowering (HIR → middle::ty IR)A-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions