1
Fork 0

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
This commit is contained in:
Michael Goulet 2023-11-19 19:14:33 -08:00 committed by GitHub
commit a7f805d277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 3 deletions

View file

@ -2827,3 +2827,23 @@ pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
)]
pub suggest_turbofish: Span,
}
#[derive(Diagnostic)]
#[diag(parse_transpose_dyn_or_impl)]
pub(crate) struct TransposeDynOrImpl<'a> {
#[primary_span]
pub span: Span,
pub kw: &'a str,
#[subdiagnostic]
pub sugg: TransposeDynOrImplSugg<'a>,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
pub(crate) struct TransposeDynOrImplSugg<'a> {
#[suggestion_part(code = "")]
pub removal_span: Span,
#[suggestion_part(code = "{kw} ")]
pub insertion_span: Span,
pub kw: &'a str,
}