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-01-09 05:29:54 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-01-11 16:53:21 +0000
commit531193853142a2564f1c667c9e8ca96c524a380b (patch)
treed6c41ab474075abbfca955b556dd9c68f9794cd4 /compiler/rustc_parse/src/errors.rs
parentb22c152958eade17a71d899b29a2d39bcc77aa48 (diff)
downloadrust-531193853142a2564f1c667c9e8ca96c524a380b.tar.gz
rust-531193853142a2564f1c667c9e8ca96c524a380b.zip
Detect struct literal needing parentheses
Fix #82051.
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 574591529f3..19eeb069a25 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -971,6 +971,24 @@ pub(crate) struct StructLiteralBodyWithoutPathSugg {
 }
 
 #[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 {
     #[primary_span]