Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebank
feat(rustc_parse): recover from pre-RFC-2000 const generics syntax Fixes #89013
This commit is contained in:
commit
1708219940
11 changed files with 180 additions and 6 deletions
|
|
@ -0,0 +1,16 @@
|
|||
trait Foo<const N: usize> {
|
||||
fn do_x(&self) -> [u8; N];
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
const T: usize = 42;
|
||||
|
||||
impl Foo<const 3> for Bar {
|
||||
//~^ERROR expected lifetime, type, or constant, found keyword `const`
|
||||
fn do_x(&self) -> [u8; 3] {
|
||||
[0u8; 3]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error: expected lifetime, type, or constant, found keyword `const`
|
||||
--> $DIR/issue-89013-no-assoc.rs:9:10
|
||||
|
|
||||
LL | impl Foo<const 3> for Bar {
|
||||
| ^^^^^
|
||||
|
|
||||
help: the `const` keyword is only needed in the definition of the type
|
||||
|
|
||||
LL - impl Foo<const 3> for Bar {
|
||||
LL + impl Foo<3> for Bar {
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
trait Foo<const N: usize> {
|
||||
fn do_x(&self) -> [u8; N];
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
const T: usize = 42;
|
||||
|
||||
impl Foo<N = 3> for Bar {
|
||||
//~^ ERROR cannot constrain an associated constant to a value
|
||||
//~| ERROR associated type bindings are not allowed here
|
||||
fn do_x(&self) -> [u8; 3] {
|
||||
[0u8; 3]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
error: cannot constrain an associated constant to a value
|
||||
--> $DIR/issue-89013-no-kw.rs:9:10
|
||||
|
|
||||
LL | impl Foo<N = 3> for Bar {
|
||||
| -^^^-
|
||||
| | |
|
||||
| | ...cannot be constrained to this value
|
||||
| this associated constant...
|
||||
|
||||
error[E0229]: associated type bindings are not allowed here
|
||||
--> $DIR/issue-89013-no-kw.rs:9:10
|
||||
|
|
||||
LL | impl Foo<N = 3> for Bar {
|
||||
| ^^^^^ associated type not allowed here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0229`.
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
trait Foo<const N: usize> {
|
||||
fn do_x(&self) -> [u8; N];
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
const T: usize = 42;
|
||||
|
||||
impl Foo<N = type 3> for Bar {
|
||||
//~^ERROR missing type to the right of `=`
|
||||
fn do_x(&self) -> [u8; 3] {
|
||||
[0u8; 3]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: missing type to the right of `=`
|
||||
--> $DIR/issue-89013-type.rs:9:13
|
||||
|
|
||||
LL | impl Foo<N = type 3> for Bar {
|
||||
| ^---- expected type, found keyword `type`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
trait Foo<const N: usize> {
|
||||
fn do_x(&self) -> [u8; N];
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
const T: usize = 42;
|
||||
|
||||
impl Foo<N = const 3> for Bar {
|
||||
//~^ ERROR expected lifetime, type, or constant, found keyword `const`
|
||||
//~| ERROR cannot constrain an associated constant to a value
|
||||
//~| ERROR associated type bindings are not allowed here
|
||||
fn do_x(&self) -> [u8; 3] {
|
||||
[0u8; 3]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
error: expected lifetime, type, or constant, found keyword `const`
|
||||
--> $DIR/issue-89013.rs:9:14
|
||||
|
|
||||
LL | impl Foo<N = const 3> for Bar {
|
||||
| ^^^^^
|
||||
|
|
||||
help: the `const` keyword is only needed in the definition of the type
|
||||
|
|
||||
LL - impl Foo<N = const 3> for Bar {
|
||||
LL + impl Foo<N = 3> for Bar {
|
||||
|
|
||||
|
||||
error: cannot constrain an associated constant to a value
|
||||
--> $DIR/issue-89013.rs:9:10
|
||||
|
|
||||
LL | impl Foo<N = const 3> for Bar {
|
||||
| -^^^^^^^^^-
|
||||
| | |
|
||||
| | ...cannot be constrained to this value
|
||||
| this associated constant...
|
||||
|
||||
error[E0229]: associated type bindings are not allowed here
|
||||
--> $DIR/issue-89013.rs:9:10
|
||||
|
|
||||
LL | impl Foo<N = const 3> for Bar {
|
||||
| ^^^^^^^^^^^ associated type not allowed here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0229`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue