about summary refs log tree commit diff
path: root/src/test/ui/const-generics/generic-function-call-in-array-length.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/generic-function-call-in-array-length.rs')
-rw-r--r--src/test/ui/const-generics/generic-function-call-in-array-length.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/generic-function-call-in-array-length.rs
new file mode 100644
index 00000000000..c8bbae29343
--- /dev/null
+++ b/src/test/ui/const-generics/generic-function-call-in-array-length.rs
@@ -0,0 +1,16 @@
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
+
+const fn foo(n: usize) -> usize { n * 2 }
+
+fn bar<const N: usize>() -> [u32; foo(N)] {
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[full]~^^ ERROR constant expression depends on a generic parameter
+    [0; foo(N)]
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+}
+
+fn main() {}