1
Fork 0

parser: recover from where clauses placed before tuple struct bodies

This commit is contained in:
León Orell Valerian Liehr 2023-01-06 17:47:21 +01:00
parent b22c152958
commit 70ddde76df
No known key found for this signature in database
GPG key ID: CD75E31CE2CFD7D9
11 changed files with 266 additions and 17 deletions

View file

@ -1237,3 +1237,27 @@ pub(crate) struct ExpectedFnPathFoundFnKeyword {
#[suggestion(applicability = "machine-applicable", code = "Fn", style = "verbose")]
pub fn_token_span: Span,
}
#[derive(Diagnostic)]
#[diag(parse_where_clause_before_tuple_struct_body)]
pub(crate) struct WhereClauseBeforeTupleStructBody {
#[primary_span]
#[label]
pub span: Span,
#[label(name_label)]
pub name: Span,
#[label(body_label)]
pub body: Span,
#[subdiagnostic]
pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
#[suggestion_part(code = "{snippet}")]
pub left: Span,
pub snippet: String,
#[suggestion_part(code = "")]
pub right: Span,
}