diff options
| author | varkor <github@varkor.com> | 2020-01-20 15:22:12 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2020-01-21 01:03:15 +0000 |
| commit | dd0507c054ea27ae836025761908d339a478e0ab (patch) | |
| tree | 46d1061dacc21dd0d2a235604364ec3db08077d9 /src/test/ui/const-generics/array-size-in-generic-struct-param.rs | |
| parent | 900811e43047fc5593f39b0363373530b02c87e0 (diff) | |
| download | rust-dd0507c054ea27ae836025761908d339a478e0ab.tar.gz rust-dd0507c054ea27ae836025761908d339a478e0ab.zip | |
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.
Diffstat (limited to 'src/test/ui/const-generics/array-size-in-generic-struct-param.rs')
| -rw-r--r-- | src/test/ui/const-generics/array-size-in-generic-struct-param.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs index f3be7b56db5..d996bf56fcc 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs @@ -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 }; |
