-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse: improve recovery for assoc eq constraints.
- Loading branch information
Showing
7 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[cfg(FALSE)] | ||
fn syntax() { | ||
bar::<Item = >(); //~ ERROR missing type to the right of `=` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[cfg(FALSE)] | ||
fn syntax() { | ||
bar::<Item = 'a>(); //~ ERROR associated lifetimes are not supported | ||
} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/parser/recover-assoc-lifetime-constraint.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|