about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2021-05-15 14:56:28 -0700
committerEsteban Kuber <esteban@kuber.com.ar>2021-11-24 20:02:09 +0000
commit7190bc3097a3f84c9d0e07d149eba4b00e4f8917 (patch)
treec3c03074b83b4ca2c87fb6622ad3c7f0fd8ff393 /src/test/ui/parser
parent311fa1f14dd8ffbbe83b229a94b17f7f1ecaf33b (diff)
downloadrust-7190bc3097a3f84c9d0e07d149eba4b00e4f8917.tar.gz
rust-7190bc3097a3f84c9d0e07d149eba4b00e4f8917.zip
Account for incorrect `impl Foo<const N: ty> {}` syntax
Fix #84946
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/const-param-decl-on-type-instead-of-impl.rs6
-rw-r--r--src/test/ui/parser/const-param-decl-on-type-instead-of-impl.stderr22
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.rs b/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.rs
new file mode 100644
index 00000000000..ecdfce1e19e
--- /dev/null
+++ b/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.rs
@@ -0,0 +1,6 @@
+struct NInts<const N: usize>([u8; N]);
+impl NInts<const N: usize> {} //~ ERROR unexpected `const` parameter declaration
+
+fn main() {
+    let _: () = 42; //~ ERROR mismatched types
+}
diff --git a/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.stderr b/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.stderr
new file mode 100644
index 00000000000..07c7c69f8d6
--- /dev/null
+++ b/src/test/ui/parser/const-param-decl-on-type-instead-of-impl.stderr
@@ -0,0 +1,22 @@
+error: unexpected `const` parameter declaration
+  --> $DIR/const-param-decl-on-type-instead-of-impl.rs:2:18
+   |
+LL | impl NInts<const N: usize> {}
+   |                  ^ expected a `const` expression, not a parameter declaration
+   |
+help: `const` parameters must be declared for the `impl`
+   |
+LL | impl<const N: usize> NInts<N> {}
+   |     ++++++++++++++++       ~
+
+error[E0308]: mismatched types
+  --> $DIR/const-param-decl-on-type-instead-of-impl.rs:5:17
+   |
+LL |     let _: () = 42;
+   |            --   ^^ expected `()`, found integer
+   |            |
+   |            expected due to this
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.