about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.rs13
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.stderr26
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs
new file mode 100644
index 00000000000..3f120cbc4d3
--- /dev/null
+++ b/src/test/ui/const-generics/const-param-before-other-params.rs
@@ -0,0 +1,13 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+fn foo<const X: (), T>(_: T) {
+    //~^ ERROR type parameters must be declared prior to const parameters
+    //~^^ ERROR const generics in any position are currently unsupported
+}
+
+fn bar<const X: (), 'a>(_: &'a ()) {
+    //~^ ERROR lifetime parameters must be declared prior to const parameters
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.stderr
new file mode 100644
index 00000000000..303ea16ca83
--- /dev/null
+++ b/src/test/ui/const-generics/const-param-before-other-params.stderr
@@ -0,0 +1,26 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-param-before-other-params.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
+error: type parameters must be declared prior to const parameters
+  --> $DIR/const-param-before-other-params.rs:4:21
+   |
+LL | fn foo<const X: (), T>(_: T) {
+   |       --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, X>`
+
+error: lifetime parameters must be declared prior to const parameters
+  --> $DIR/const-param-before-other-params.rs:9:21
+   |
+LL | fn bar<const X: (), 'a>(_: &'a ()) {
+   |       --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, X>`
+
+error: const generics in any position are currently unsupported
+  --> $DIR/const-param-before-other-params.rs:4:14
+   |
+LL | fn foo<const X: (), T>(_: T) {
+   |              ^
+
+error: aborting due to 3 previous errors
+