about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-05-11 18:58:15 +0100
committervarkor <github@varkor.com>2019-05-28 21:34:42 +0100
commit55dcc20f9a605e19d3c34bfc7f84380f079350fb (patch)
tree9b1b6f842fa553652e97e3c4f8e494f13eec6ca2
parent4ad5c62550aa402716f9c845e8fdfc1c89e8a4fa (diff)
downloadrust-55dcc20f9a605e19d3c34bfc7f84380f079350fb.tar.gz
rust-55dcc20f9a605e19d3c34bfc7f84380f079350fb.zip
Add tests for uninferred consts during codegen
-rw-r--r--src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs18
-rw-r--r--src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr6
-rw-r--r--src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs18
-rw-r--r--src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr6
4 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs
new file mode 100644
index 00000000000..2e555d11aba
--- /dev/null
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs
@@ -0,0 +1,18 @@
+// run-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+use std::fmt;
+
+struct Array<T, const N: usize>([T; N]);
+
+impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<T, {N}> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_list().entries(self.0.iter()).finish()
+    }
+}
+
+fn main() {
+    println!("{:?}", Array([1, 2, 3]));
+}
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr
new file mode 100644
index 00000000000..eb2e446396c
--- /dev/null
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr
@@ -0,0 +1,6 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/uninferred-consts-during-codegen-1.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs
new file mode 100644
index 00000000000..7a1a4f49794
--- /dev/null
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs
@@ -0,0 +1,18 @@
+// run-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+use std::fmt;
+
+struct Array<T>(T);
+
+impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<[T; N]> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_list().entries((&self.0 as &[T]).iter()).finish()
+    }
+}
+
+fn main() {
+    println!("{:?}", Array([1, 2, 3]));
+}
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr
new file mode 100644
index 00000000000..eaa20bb7892
--- /dev/null
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr
@@ -0,0 +1,6 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/uninferred-consts-during-codegen-2.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+