Repository navigation
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call 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.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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.Relevant to the types team, which will review and decide on the PR/issue.
Description
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)Area: const generics (parameters and arguments)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call 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.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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.Relevant to the types team, which will review and decide on the PR/issue.
Activity
meithecatte commentedon Feb 4, 2026
@rustbot claim
biscuitrescue commentedon Feb 10, 2026
Hi @meithecatte, are you still working on this? I'm interested in working on this and would love to help out if it's no bother to you.
meithecatte commentedon Feb 10, 2026
Hi! I ended up getting deep into the weeds. If you'd like to work on this instead, feel free.
biscuitrescue commentedon Feb 10, 2026
Sure, thankyou. @rustbot claim
alv-around commentedon Feb 10, 2026
Oops! I accidentally drafted a fix without realizing this was already claimed last week. Sorry about that, @biscuitrescue! I'm happy to collaborate on this PR together, or you can cherry-pick what I've done into your own branch—whatever is easiest for you! 🦀
biscuitrescue commentedon Feb 11, 2026
@alv-around I already implemented the fix but I'd love to double check and compare. Never hurts to be careful ;)
biscuitrescue commentedon Feb 11, 2026
@BoxyUwU I have implemented the fix but I wanted to clarify if my approach aligns with how this should be solved.
The current implementation adds a separate
ty::Arrayarm alongside the existingty::Tuple. The Array arm is similar to how the Tuple fix was done in #150713. The logic for both only differs in how element types are extracted.Which approach would you prefer?
or
biscuitrescue commentedon Feb 11, 2026
Nevermind, I tried to implement both in the same arm, but it creates more problems than its worth due because requires an inner match on the same variable that's running on the outer match. Separate arms look cleaner.
Rollup merge of rust-lang#152492 - biscuitrescue:fix-array-valtree-wf…
Unrolled build for #152492
Rollup merge of #152492 - biscuitrescue:fix-array-valtree-wf, r=BoxyUwU