about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-11 10:46:35 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-18 17:11:34 +0200
commit82ebbd7d6b6d3f0ec1560c823320aab696463770 (patch)
tree06feadd22488a9cc8b6d9188259ab01731768fca /src
parentc7d16df1d81934ff33d9d421ac2dc34c893ad68f (diff)
downloadrust-82ebbd7d6b6d3f0ec1560c823320aab696463770.tar.gz
rust-82ebbd7d6b6d3f0ec1560c823320aab696463770.zip
add test for let-bindings
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs15
-rw-r--r--src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr18
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs b/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs
new file mode 100644
index 00000000000..d96788f8cd1
--- /dev/null
+++ b/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs
@@ -0,0 +1,15 @@
+#![feature(const_generics, const_evaluatable_checked)]
+#![allow(incomplete_features)]
+
+// We do not yet want to support let-bindings in abstract consts,
+// so this test should keep failing for now.
+fn test<const N: usize>() -> [u8; { let x = N; N + 1 }] where [u8; { let x = N; N + 1 }]: Default {
+    //~^ ERROR constant expression depends
+    //~| ERROR constant expression depends
+    Default::default()
+}
+
+fn main() {
+    let x = test::<31>();
+    assert_eq!(x, [0; 32]);
+}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr b/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr
new file mode 100644
index 00000000000..95fb48bd434
--- /dev/null
+++ b/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr
@@ -0,0 +1,18 @@
+error: constant expression depends on a generic parameter
+  --> $DIR/let-bindings.rs:6:91
+   |
+LL | fn test<const N: usize>() -> [u8; { let x = N; N + 1 }] where [u8; { let x = N; N + 1 }]: Default {
+   |                                                                                           ^^^^^^^ required by this bound in `test::{{constant}}#0`
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+  --> $DIR/let-bindings.rs:6:30
+   |
+LL | fn test<const N: usize>() -> [u8; { let x = N; N + 1 }] where [u8; { let x = N; N + 1 }]: Default {
+   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+