about summary refs log tree commit diff
path: root/src/test/ui/const-generics
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2020-01-21 23:07:07 +0000
committervarkor <github@varkor.com>2020-02-22 00:28:18 +0000
commit039045c49bec06f3a42aed90d3bc94520d92514e (patch)
tree3091e29070119dfda744b3c9661f49fccd8a996b /src/test/ui/const-generics
parent750e673491114cd8454f1715ce1fda8dd02b7ac0 (diff)
downloadrust-039045c49bec06f3a42aed90d3bc94520d92514e.tar.gz
rust-039045c49bec06f3a42aed90d3bc94520d92514e.zip
Move generic arg / param validation to `create_substs_for_generic_args`
Diffstat (limited to 'src/test/ui/const-generics')
-rw-r--r--src/test/ui/const-generics/const-arg-type-arg-misordered.rs10
-rw-r--r--src/test/ui/const-generics/const-arg-type-arg-misordered.stderr17
-rw-r--r--src/test/ui/const-generics/const-param-after-const-literal-arg.rs10
-rw-r--r--src/test/ui/const-generics/const-param-after-const-literal-arg.stderr8
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.rs1
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.stderr12
6 files changed, 56 insertions, 2 deletions
diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs
new file mode 100644
index 00000000000..f024eb6a957
--- /dev/null
+++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs
@@ -0,0 +1,10 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+type Array<T, const N: usize> = [T; N];
+
+fn foo<const N: usize>() -> Array<N, ()> { //~ ERROR constant provided when a type was expected
+    unimplemented!()
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
new file mode 100644
index 00000000000..225e1cd547e
--- /dev/null
+++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
@@ -0,0 +1,17 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-arg-type-arg-misordered.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error[E0747]: constant provided when a type was expected
+  --> $DIR/const-arg-type-arg-misordered.rs:6:35
+   |
+LL | fn foo<const N: usize>() -> Array<N, ()> {
+   |                                   ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0747`.
diff --git a/src/test/ui/const-generics/const-param-after-const-literal-arg.rs b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs
new file mode 100644
index 00000000000..683bcc867c7
--- /dev/null
+++ b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+struct Foo<const A: usize, const B: usize>;
+
+impl<const A: usize> Foo<1, A> {} // ok
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-param-after-const-literal-arg.stderr b/src/test/ui/const-generics/const-param-after-const-literal-arg.stderr
new file mode 100644
index 00000000000..a949a6ec9ff
--- /dev/null
+++ b/src/test/ui/const-generics/const-param-after-const-literal-arg.stderr
@@ -0,0 +1,8 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-param-after-const-literal-arg.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
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
index 5bdbfd8ff1f..2c81681b85e 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.rs
+++ b/src/test/ui/const-generics/const-param-before-other-params.rs
@@ -1,4 +1,5 @@
 #![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
 
 fn bar<const X: (), 'a>(_: &'a ()) {
     //~^ ERROR lifetime parameters must be declared prior to const parameters
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
index 87622f7e500..fccf732de4c 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.stderr
+++ b/src/test/ui/const-generics/const-param-before-other-params.stderr
@@ -1,14 +1,22 @@
 error: lifetime parameters must be declared prior to const parameters
-  --> $DIR/const-param-before-other-params.rs:3:21
+  --> $DIR/const-param-before-other-params.rs:4:21
    |
 LL | fn bar<const X: (), 'a>(_: &'a ()) {
    |       --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
 
 error: type parameters must be declared prior to const parameters
-  --> $DIR/const-param-before-other-params.rs:7:21
+  --> $DIR/const-param-before-other-params.rs:8:21
    |
 LL | fn foo<const X: (), T>(_: &T) {
    |       --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
 
+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)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
 error: aborting due to 2 previous errors