parse: improve recovery for assoc eq constraints.
This commit is contained in:
parent
f91de44d07
commit
2972bb37b8
7 changed files with 111 additions and 1 deletions
7
src/test/ui/parser/recover-assoc-const-constraint.rs
Normal file
7
src/test/ui/parser/recover-assoc-const-constraint.rs
Normal 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() {}
|
||||
20
src/test/ui/parser/recover-assoc-const-constraint.stderr
Normal file
20
src/test/ui/parser/recover-assoc-const-constraint.stderr
Normal 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
|
||||
|
||||
6
src/test/ui/parser/recover-assoc-eq-missing-term.rs
Normal file
6
src/test/ui/parser/recover-assoc-eq-missing-term.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#[cfg(FALSE)]
|
||||
fn syntax() {
|
||||
bar::<Item = >(); //~ ERROR missing type to the right of `=`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
17
src/test/ui/parser/recover-assoc-eq-missing-term.stderr
Normal file
17
src/test/ui/parser/recover-assoc-eq-missing-term.stderr
Normal 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
|
||||
|
||||
6
src/test/ui/parser/recover-assoc-lifetime-constraint.rs
Normal file
6
src/test/ui/parser/recover-assoc-lifetime-constraint.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#[cfg(FALSE)]
|
||||
fn syntax() {
|
||||
bar::<Item = 'a>(); //~ ERROR associated lifetimes are not supported
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
12
src/test/ui/parser/recover-assoc-lifetime-constraint.stderr
Normal file
12
src/test/ui/parser/recover-assoc-lifetime-constraint.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue