Skip to content

Commit a9e876c

Browse files
Rollup merge of #152492 - biscuitrescue:fix-array-valtree-wf, r=BoxyUwU
mGCA: Enforce WF element types for array valtrees Fixes rust-lang/rust#152125 Extends WellFormedness checking for const generics to validate that array element types in ValTrees match the declared element type. ### Problem Before commit, this would have incorrectly compiled ``` rust #![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] }>(); } ``` ### Solution Added a `ty::Array` arm to checking WellFormedness (similar to the existing `ty::Tuple` arm from rust-lang/rust#150713) which creates `ConstArgHasType` obligations for each array element, ensuring they match the array's declared element type. I attempted to combine the `Tuple` and `Array` arms into a single arm, but this proved difficult due to pattern matching limitations, and the separate arm is more readable anyway. ### Tests Added UI test which verifies that the type mismatch is now properly caught, and also returns an appropriate test message r? @BoxyUwU
2 parents 43dbf6b + dbea7ea commit a9e876c

0 file changed

File tree

    0 commit comments

    Comments
     (0)