about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-05-31 13:33:58 +0200
committerGitHub <noreply@github.com>2019-05-31 13:33:58 +0200
commit2106d57c3560701ca69b66d7ffb77e573aa9fa9f (patch)
tree433372b2fa1589ca18349240c7f1d9b46ae24ad2
parent860deae4c6dea01cb0213dff454b17f5d507079b (diff)
parent0fdd4191adb998991742c7f63f49b1a6c4e4ec3d (diff)
downloadrust-2106d57c3560701ca69b66d7ffb77e573aa9fa9f.tar.gz
rust-2106d57c3560701ca69b66d7ffb77e573aa9fa9f.zip
Rollup merge of #61344 - varkor:const-failed-to-life-ice, r=Centril
Add regression test for const generics ICE

Closes https://github.com/rust-lang/rust/issues/60879.
-rw-r--r--src/test/ui/const-generics/const-generic-array-wrapper.rs18
-rw-r--r--src/test/ui/const-generics/const-generic-array-wrapper.stderr6
2 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.rs b/src/test/ui/const-generics/const-generic-array-wrapper.rs
new file mode 100644
index 00000000000..adffe32d67a
--- /dev/null
+++ b/src/test/ui/const-generics/const-generic-array-wrapper.rs
@@ -0,0 +1,18 @@
+// run-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+struct Foo<T, const N: usize>([T; {N}]);
+
+impl<T, const N: usize> Foo<T, {N}> {
+    fn foo(&self) -> usize {
+        {N}
+    }
+}
+
+fn main() {
+    let foo = Foo([0u32; 21]);
+    assert_eq!(foo.0, [0u32; 21]);
+    assert_eq!(foo.foo(), 21);
+}
diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.stderr b/src/test/ui/const-generics/const-generic-array-wrapper.stderr
new file mode 100644
index 00000000000..f92e11d47ed
--- /dev/null
+++ b/src/test/ui/const-generics/const-generic-array-wrapper.stderr
@@ -0,0 +1,6 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-generic-array-wrapper.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+