about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/errors.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-01-11 21:08:07 +0100
committerGitHub <noreply@github.com>2023-01-11 21:08:07 +0100
commit7ee3fd2edce794a452f9b91dd2cb8fe8f5bc151a (patch)
tree02cb97bec9ae9941481353f692f995294f6c83d8 /compiler/rustc_parse/src/errors.rs
parentef4046e4f3932991971cdb64915172899532aece (diff)
parent531193853142a2564f1c667c9e8ca96c524a380b (diff)
downloadrust-7ee3fd2edce794a452f9b91dd2cb8fe8f5bc151a.tar.gz
rust-7ee3fd2edce794a452f9b91dd2cb8fe8f5bc151a.zip
Rollup merge of #106620 - estebank:issue-82051, r=davidtwco
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]