-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #117891 - compiler-errors:recover-for-dyn, r=davidtwco
Recover `dyn` and `impl` after `for<...>` Recover `dyn` and `impl` after `for<...>` in types. Reuses the logic for parsing bare trait objects, so it doesn't fix cases like `for<'a> dyn Trait + dyn Trait` or anything, but that seems somewhat of a different issue. Parsing recovery logic is a bit involved, but I couldn't find a way to simplify it. Fixes #117882
- Loading branch information
Showing
5 changed files
with
95 additions
and
3 deletions.
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
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,9 @@ | ||
trait Trait {} | ||
|
||
fn test(_: &for<'a> dyn Trait) {} | ||
//~^ ERROR `for<...>` expected after `dyn`, not before | ||
|
||
fn test2(_: for<'a> impl Trait) {} | ||
//~^ ERROR `for<...>` expected after `impl`, not before | ||
|
||
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,26 @@ | ||
error: `for<...>` expected after `dyn`, not before | ||
--> $DIR/recover-hrtb-before-dyn-impl-kw.rs:3:21 | ||
| | ||
LL | fn test(_: &for<'a> dyn Trait) {} | ||
| ^^^ | ||
| | ||
help: move `dyn` before the `for<...>` | ||
| | ||
LL - fn test(_: &for<'a> dyn Trait) {} | ||
LL + fn test(_: &dyn for<'a> Trait) {} | ||
| | ||
|
||
error: `for<...>` expected after `impl`, not before | ||
--> $DIR/recover-hrtb-before-dyn-impl-kw.rs:6:21 | ||
| | ||
LL | fn test2(_: for<'a> impl Trait) {} | ||
| ^^^^ | ||
| | ||
help: move `impl` before the `for<...>` | ||
| | ||
LL - fn test2(_: for<'a> impl Trait) {} | ||
LL + fn test2(_: impl for<'a> Trait) {} | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|