]> git.lizzy.rs Git - rust.git/commitdiff
add test for closures in abstract consts
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Mon, 21 Sep 2020 20:01:18 +0000 (22:01 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Mon, 21 Sep 2020 20:01:18 +0000 (22:01 +0200)
src/test/ui/const-generics/const_evaluatable_checked/closures.rs [new file with mode: 0644]
src/test/ui/const-generics/const_evaluatable_checked/closures.stderr [new file with mode: 0644]

diff --git a/src/test/ui/const-generics/const_evaluatable_checked/closures.rs b/src/test/ui/const-generics/const_evaluatable_checked/closures.rs
new file mode 100644 (file)
index 0000000..32f4359
--- /dev/null
@@ -0,0 +1,6 @@
+#![feature(const_generics, const_evaluatable_checked)]
+#![allow(incomplete_features)]
+fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
+//~^ ERROR overly complex generic constant
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/closures.stderr b/src/test/ui/const-generics/const_evaluatable_checked/closures.stderr
new file mode 100644 (file)
index 0000000..7bb23f1
--- /dev/null
@@ -0,0 +1,15 @@
+error: overly complex generic constant
+  --> $DIR/closures.rs:3:35
+   |
+LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
+   |                                   ^^^^^^^^^^^^^
+   |
+note: unsupported rvalue
+  --> $DIR/closures.rs:3:39
+   |
+LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
+   |                                       ^^^^^^^
+   = help: consider moving this anonymous constant into a `const` function
+
+error: aborting due to previous error
+