Detect struct literal needing parentheses

Fix #82051.
This commit is contained in:
Esteban Küber 2023-01-09 05:29:54 +00:00
parent b22c152958
commit 5311938531
8 changed files with 86 additions and 15 deletions

View file

@ -970,6 +970,24 @@ pub(crate) struct StructLiteralBodyWithoutPathSugg {
pub after: Span,
}
#[derive(Diagnostic)]
#[diag(parse_struct_literal_needing_parens)]
pub(crate) struct StructLiteralNeedingParens {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub sugg: StructLiteralNeedingParensSugg,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
pub(crate) struct StructLiteralNeedingParensSugg {
#[suggestion_part(code = "(")]
pub before: Span,
#[suggestion_part(code = ")")]
pub after: Span,
}
#[derive(Diagnostic)]
#[diag(parse_unmatched_angle_brackets)]
pub(crate) struct UnmatchedAngleBrackets {