parse: improve recovery for assoc eq constraints.

This commit is contained in:
Mazdak Farrokhzad 2020-03-22 06:09:24 +01:00
parent f91de44d07
commit 2972bb37b8
7 changed files with 111 additions and 1 deletions

View file

@ -0,0 +1,7 @@
#[cfg(FALSE)]
fn syntax() {
bar::<Item = 42>(); //~ ERROR cannot constrain an associated constant to a value
bar::<Item = { 42 }>(); //~ ERROR cannot constrain an associated constant to a value
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: cannot constrain an associated constant to a value
--> $DIR/recover-assoc-const-constraint.rs:3:11
|
LL | bar::<Item = 42>();
| ----^^^--
| | |
| | the value is given in this expression
| the value constrains this associated constant
error: cannot constrain an associated constant to a value
--> $DIR/recover-assoc-const-constraint.rs:4:11
|
LL | bar::<Item = { 42 }>();
| ----^^^------
| | |
| | the value is given in this expression
| the value constrains this associated constant
error: aborting due to 2 previous errors

View file

@ -0,0 +1,6 @@
#[cfg(FALSE)]
fn syntax() {
bar::<Item = >(); //~ ERROR missing type to the right of `=`
}
fn main() {}

View file

@ -0,0 +1,17 @@
error: missing type to the right of `=`
--> $DIR/recover-assoc-eq-missing-term.rs:3:11
|
LL | bar::<Item = >();
| ^^^^^^
|
help: to constrain the associated type, add a type after `=`
|
LL | bar::<Item = TheType >();
| ^^^^^^^^^^^^^^
help: remove the `=` if `Item` is a type
|
LL | bar::<Item >();
| --
error: aborting due to previous error

View file

@ -0,0 +1,6 @@
#[cfg(FALSE)]
fn syntax() {
bar::<Item = 'a>(); //~ ERROR associated lifetimes are not supported
}
fn main() {}

View file

@ -0,0 +1,12 @@
error: associated lifetimes are not supported
--> $DIR/recover-assoc-lifetime-constraint.rs:3:11
|
LL | bar::<Item = 'a>();
| ^^^^^^^--
| |
| the lifetime is given here
|
= help: if you meant to specify a trait object, write `dyn Trait + 'lifetime`
error: aborting due to previous error