1
Fork 0

Account for (pat if expr) => {}

When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix #100825.
This commit is contained in:
Esteban Küber 2023-11-06 23:31:13 +00:00
parent db39068ad7
commit c47318983b
5 changed files with 132 additions and 47 deletions

View file

@ -1281,6 +1281,24 @@ pub(crate) struct ParenthesesInForHeadSugg {
pub right: Span,
}
#[derive(Diagnostic)]
#[diag(parse_unexpected_parentheses_in_match_arm_pattern)]
pub(crate) struct ParenthesesInMatchPat {
#[primary_span]
pub span: Vec<Span>,
#[subdiagnostic]
pub sugg: ParenthesesInMatchPatSugg,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
pub(crate) struct ParenthesesInMatchPatSugg {
#[suggestion_part(code = "")]
pub left: Span,
#[suggestion_part(code = "")]
pub right: Span,
}
#[derive(Diagnostic)]
#[diag(parse_doc_comment_on_param_type)]
pub(crate) struct DocCommentOnParamType {