]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/const-generics/array-size-in-generic-struct-param.rs
1 // Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
4 #![cfg_attr(full, feature(const_generics))]
5 #![cfg_attr(full, allow(incomplete_features))]
6 #![cfg_attr(min, feature(min_const_generics))]
9 struct ArithArrayLen
<const N
: usize>([u32; 0 + N
]);
10 //[full]~^ ERROR constant expression depends on a generic parameter
11 //[min]~^^ ERROR generic parameters may not be used in const operations
13 #[derive(PartialEq, Eq)]
18 struct B
<const CFG
: Config
> {
19 //[min]~^ ERROR `Config` is forbidden
20 arr
: [u8; CFG
.arr_size
],
21 //[full]~^ ERROR constant expression depends on a generic parameter
22 //[min]~^^ ERROR generic parameters may not be used in const operations
25 const C
: Config
= Config { arr_size: 5 }
;
28 let b
= B
::<C
> { arr: [1, 2, 3, 4, 5] }
;
29 assert_eq
!(b
.arr
.len(), 5);