2020-08-10 18:50:58 +00:00
|
|
|
// Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
|
2020-08-09 06:19:57 +00:00
|
|
|
// revisions: full min
|
|
|
|
|
2021-08-30 10:59:53 +02:00
|
|
|
#![cfg_attr(full, feature(generic_const_exprs, adt_const_params))]
|
2020-08-09 06:19:57 +00:00
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
2020-01-05 23:00:47 +00:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
2020-01-20 15:22:12 +00:00
|
|
|
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
2021-08-27 18:04:57 +02:00
|
|
|
//[full]~^ ERROR unconstrained generic constant
|
2020-10-12 22:27:59 +01:00
|
|
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
2020-01-05 23:00:47 +00:00
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
struct Config {
|
|
|
|
arr_size: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B<const CFG: Config> {
|
2020-08-18 22:44:06 +02:00
|
|
|
//[min]~^ ERROR `Config` is forbidden
|
2020-08-09 06:19:57 +00:00
|
|
|
arr: [u8; CFG.arr_size],
|
2021-08-27 18:04:57 +02:00
|
|
|
//[full]~^ ERROR overly complex generic constant
|
2020-10-12 22:27:59 +01:00
|
|
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
2020-01-05 23:00:47 +00: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);
|
|
|
|
}
|