1
Fork 0

Make TooGeneric error in WF checking a proper error

`TooGeneric` is encountered during WF checking when we cannot determine that a constant involving a generic parameter will always be evaluated successfully (rather than resulting in an error). In these cases, the burden of proof should be with the caller, so that we can avoid post-monomorphisation tim errors (which was the previous previous behaviour). This commit ensures that this situation produces a proper compiler error, rather than silently ignoring it or ICEing.
This commit is contained in:
varkor 2020-01-20 15:22:12 +00:00
parent 900811e430
commit dd0507c054
3 changed files with 45 additions and 16 deletions

View file

@ -1,10 +1,9 @@
// 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
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
//~^ ERROR constant expression depends on a generic parameter
#[derive(PartialEq, Eq)]
struct Config {
@ -12,7 +11,7 @@ struct Config {
}
struct B<const CFG: Config> {
arr: [u8; CFG.arr_size], // ok
arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter
}
const C: Config = Config { arr_size: 5 };