Skip to content

MGCA: support tuple constructor calls as a direct const argument #150610

@BoxyUwU

Description

@BoxyUwU

We currently support Enum::Variant { field: N } and Struct { field: N } as const arguments under min_generic_const_args. We should also support Enum::Variant(N) and Struct(N) syntax.

#![feature(min_generic_const_args, adt_const_params)]

#[derive(Eq, PartialEq, core::marker::ConstParamTy)]
enum Option<T> {
    Some(T),
    None,
}

fn takes_option<const O: Option<u32>() {}

fn generic_caller<const N: u32>() {
    takes_option::<{ Option::<u32>::Some(N) }>();
    takes_option::<{ <Option<u32>>::Some(N) }>();
}

These should lower directly to a ConstKind::Value in HIR ty lowering

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions