Account for incorrect impl Foo<const N: ty> {} syntax

Fix #84946
This commit is contained in:
Esteban Küber 2021-05-15 14:56:28 -07:00 committed by Esteban Kuber
parent 311fa1f14d
commit 7190bc3097
9 changed files with 206 additions and 54 deletions

View file

@ -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
}

View file

@ -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`.