about summary refs log tree commit diff
path: root/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
diff options
context:
space:
mode:
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.rs23
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);
+}