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:
commit
a7f805d277
5 changed files with 95 additions and 3 deletions
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue