]> git.lizzy.rs Git - rust.git/commitdiff
Add regression test for #61522
authorvarkor <github@varkor.com>
Wed, 8 Apr 2020 23:57:41 +0000 (00:57 +0100)
committervarkor <github@varkor.com>
Thu, 9 Apr 2020 10:53:28 +0000 (11:53 +0100)
src/test/ui/const-generics/issue-61522-array-len-succ.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-61522-array-len-succ.stderr [new file with mode: 0644]

diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issue-61522-array-len-succ.rs
new file mode 100644 (file)
index 0000000..3b627a5
--- /dev/null
@@ -0,0 +1,14 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+//~^ ERROR constant expression depends on a generic parameter
+
+impl<const COUNT: usize> MyArray<COUNT> {
+    fn inner(&self) -> &[u8; COUNT + 1] {
+        //~^ ERROR constant expression depends on a generic parameter
+        &self.0
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr
new file mode 100644 (file)
index 0000000..0c4bd4a
--- /dev/null
@@ -0,0 +1,26 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/issue-61522-array-len-succ.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error: constant expression depends on a generic parameter
+  --> $DIR/issue-61522-array-len-succ.rs:4:40
+   |
+LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+   |                                        ^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+  --> $DIR/issue-61522-array-len-succ.rs:8:24
+   |
+LL |     fn inner(&self) -> &[u8; COUNT + 1] {
+   |                        ^^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+