about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-18 16:50:57 -0700
committerGitHub <noreply@github.com>2020-07-18 16:50:57 -0700
commit1a54b61e39b2c5d383da622d3d390bcda32f6b3c (patch)
tree005e7175251757d1c8f7a74d8848e8316acd124d
parent43ba8409d7c7f93d6f0b3c22fe1b193788ff6162 (diff)
parent0bac36105e24a1abef87644c3bcd1b3d92169b5d (diff)
downloadrust-1a54b61e39b2c5d383da622d3d390bcda32f6b3c.tar.gz
rust-1a54b61e39b2c5d383da622d3d390bcda32f6b3c.zip
Rollup merge of #74445 - lcnr:const-generic-ty-decl, r=Dylan-DPC
add test for #62878

forgot to push this as part of #74159

r? @Dylan-DPC
-rw-r--r--src/test/ui/const-generics/issues/issue-62878.rs11
-rw-r--r--src/test/ui/const-generics/issues/issue-62878.stderr37
2 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-62878.rs b/src/test/ui/const-generics/issues/issue-62878.rs
new file mode 100644
index 00000000000..ccc05fdf100
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-62878.rs
@@ -0,0 +1,11 @@
+#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
+
+fn foo<const N: usize, const A: [u8; N]>() {}
+//~^ ERROR the type of const parameters must not
+
+fn main() {
+    foo::<_, {[1]}>();
+    //~^ ERROR wrong number of const arguments
+    //~| ERROR wrong number of type arguments
+    //~| ERROR mismatched types
+}
diff --git a/src/test/ui/const-generics/issues/issue-62878.stderr b/src/test/ui/const-generics/issues/issue-62878.stderr
new file mode 100644
index 00000000000..fe0990d8241
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-62878.stderr
@@ -0,0 +1,37 @@
+error[E0770]: the type of const parameters must not depend on other generic parameters
+  --> $DIR/issue-62878.rs:3:38
+   |
+LL | fn foo<const N: usize, const A: [u8; N]>() {}
+   |                                      ^ the type must not depend on the parameter `N`
+
+warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/issue-62878.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+
+error[E0107]: wrong number of const arguments: expected 2, found 1
+  --> $DIR/issue-62878.rs:7:5
+   |
+LL |     foo::<_, {[1]}>();
+   |     ^^^^^^^^^^^^^^^ expected 2 const arguments
+
+error[E0107]: wrong number of type arguments: expected 0, found 1
+  --> $DIR/issue-62878.rs:7:11
+   |
+LL |     foo::<_, {[1]}>();
+   |           ^ unexpected type argument
+
+error[E0308]: mismatched types
+  --> $DIR/issue-62878.rs:7:15
+   |
+LL |     foo::<_, {[1]}>();
+   |               ^^^ expected `usize`, found array `[{integer}; 1]`
+
+error: aborting due to 4 previous errors; 1 warning emitted
+
+Some errors have detailed explanations: E0107, E0308, E0770.
+For more information about an error, try `rustc --explain E0107`.