about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/errors.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-11-06 23:31:13 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-11-29 18:47:32 +0000
commitc47318983bcad308e0cf438fcd7d7104db607b1a (patch)
treed38273dd7f0bf7cce65f2b8da3e443901fe96faa /compiler/rustc_parse/src/errors.rs
parentdb39068ad7060bf2375535e50aeb3e42d9f939bd (diff)
downloadrust-c47318983bcad308e0cf438fcd7d7104db607b1a.tar.gz
rust-c47318983bcad308e0cf438fcd7d7104db607b1a.zip
Account for `(pat if expr) => {}`
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix #100825.
Diffstat (limited to 'compiler/rustc_parse/src/errors.rs')
-rw-r--r--compiler/rustc_parse/src/errors.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs
index 714ec7f2742..03e047b297d 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -1282,6 +1282,24 @@ pub(crate) struct ParenthesesInForHeadSugg {
 }
 
 #[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 {
     #[primary_span]