diff options
| author | varkor <github@varkor.com> | 2020-01-05 23:00:47 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2020-01-05 23:00:47 +0000 |
| commit | adb46fd0a49108f08bd0d4b8c95317cfbcbb7941 (patch) | |
| tree | b553ad5b460ca34b40c604808f7f894376b55238 /src/test/ui/const-generics/array-size-in-generic-struct-param.rs | |
| parent | 760ce94c69ca510d44087291c311296f6d9ccdf5 (diff) | |
| download | rust-adb46fd0a49108f08bd0d4b8c95317cfbcbb7941.tar.gz rust-adb46fd0a49108f08bd0d4b8c95317cfbcbb7941.zip | |
Silence `TooGeneric` error
This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.
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 | 23 |
1 files changed, 23 insertions, 0 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 new file mode 100644 index 00000000000..f3be7b56db5 --- /dev/null +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs @@ -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); +} |
