1
Fork 0

Auto merge of #106537 - fmease:recover-where-clause-before-tuple-struct-body, r=estebank

Recover from where clauses placed before tuple struct bodies

Open to any suggestions regarding the phrasing of the diagnostic.

Fixes #100790.
`@rustbot` label A-diagnostics
r? diagnostics
This commit is contained in:
bors 2023-01-12 02:16:16 +00:00
commit d4203eda5f
11 changed files with 266 additions and 17 deletions

View file

@ -1255,3 +1255,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,
}