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:
authorbors <bors@rust-lang.org>2020-01-06 09:31:27 +0000
committerbors <bors@rust-lang.org>2020-01-06 09:31:27 +0000
commita80e63f3fa77792e848e3b248acf4c0acda2e310 (patch)
tree6e9574bac0128d5184af68d208b2ee8d9e98e416 /src/test/ui/const-generics/array-size-in-generic-struct-param.rs
parent33640f0e03af2fb31ce380d5389d5545f24ce29a (diff)
parent34716a31db9371501fe98100a7aa1566f37c1d23 (diff)
downloadrust-a80e63f3fa77792e848e3b248acf4c0acda2e310.tar.gz
rust-a80e63f3fa77792e848e3b248acf4c0acda2e310.zip
Auto merge of #67917 - Dylan-DPC:rollup-id05y91, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #67800 (Fix ICE involving calling `Instance.ty` during const evaluation)
 - #67873 (change remove to have a PartialEq bound)
 - #67897 (Use `as_deref()` to replace `as_ref().map(...)`)
 - #67906 (Silence `TooGeneric` error)
 - #67912 (macros: typo fix)
 - #67915 (Use Self instead of $type)

Failed merges:

r? @ghost
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);
+}