Skip to content

mGCA: type check arguments to array expressions #152125

@BoxyUwU

Description

@BoxyUwU

WellFormed goals for const generics currently don't require that the constituent consts of an array valtree have the same type as the element type of the valtree. This allows the following code to pass even though Bar is not of type Foo:

#![feature(adt_const_params, min_generic_const_args)]

use std::marker::ConstParamTy;

#[derive(Eq, PartialEq, ConstParamTy)]
struct Foo;

struct Bar;

fn foo<const N: [Foo; 1]>() {}

fn main() {
    foo::<{ [Bar] }>();
}

See #150713 as an example of where this was previously implemented for tuples. Implementing this will involve extending the Tuple arm to also cover Arrays.

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-adt_const_params`#![feature(adt_const_params)]`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.T-typesRelevant to the types 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