2020-08-09 01:19:57 -05:00
|
|
|
// Tests that array sizes that depend on const-params does not yet work.
|
|
|
|
// revisions: full min
|
|
|
|
|
|
|
|
#![cfg_attr(full, feature(const_generics))]
|
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
|
|
|
#![cfg_attr(min, feature(min_const_generics))]
|
2020-01-05 17:00:47 -06:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
2020-01-20 09:22:12 -06:00
|
|
|
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
2020-08-09 01:19:57 -05:00
|
|
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
|
|
|
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
2020-01-05 17:00:47 -06:00
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
struct Config {
|
|
|
|
arr_size: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B<const CFG: Config> {
|
2020-08-09 01:19:57 -05:00
|
|
|
//[min]~^ ERROR using `Config` as const generic parameters is forbidden
|
|
|
|
arr: [u8; CFG.arr_size],
|
|
|
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
|
|
|
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
|
2020-01-05 17:00:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const C: Config = Config { arr_size: 5 };
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let b = B::<C> { arr: [1, 2, 3, 4, 5] };
|
|
|
|
assert_eq!(b.arr.len(), 5);
|
|
|
|
}
|