1
Fork 0

Silence TooGeneric error

This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.
This commit is contained in:
varkor 2020-01-05 23:00:47 +00:00
parent 760ce94c69
commit adb46fd0a4
4 changed files with 41 additions and 1 deletions

View file

@ -0,0 +1,23 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]); // ok
#[derive(PartialEq, Eq)]
struct Config {
arr_size: usize,
}
struct B<const CFG: Config> {
arr: [u8; CFG.arr_size], // ok
}
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);
}