about summary refs log tree commit diff
path: root/src/librustc_errors/diagnostic.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-05-29 09:24:59 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-06-10 14:09:51 -0700
commitc29b3fa1484c625bd34cb4d94fc76f36c6233447 (patch)
tree20e2737f33c3ae1a777c4524a34a549ed1117795 /src/librustc_errors/diagnostic.rs
parentbb8674837a9cc5225020e07fc3f164762bb4c11c (diff)
On recursive ADT, provide indirection structured suggestion
Diffstat (limited to 'src/librustc_errors/diagnostic.rs')
-rw-r--r--src/librustc_errors/diagnostic.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index cff83c3d5cd..acaa26c6ad2 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -296,6 +296,29 @@ impl Diagnostic {
         self
     }
 
+    pub fn multipart_suggestions(
+        &mut self,
+        msg: &str,
+        suggestions: Vec<Vec<(Span, String)>>,
+        applicability: Applicability,
+    ) -> &mut Self {
+        self.suggestions.push(CodeSuggestion {
+            substitutions: suggestions
+                .into_iter()
+                .map(|suggestion| Substitution {
+                    parts: suggestion
+                        .into_iter()
+                        .map(|(span, snippet)| SubstitutionPart { snippet, span })
+                        .collect(),
+                })
+                .collect(),
+            msg: msg.to_owned(),
+            style: SuggestionStyle::ShowCode,
+            applicability,
+        });
+        self
+    }
+
     /// Prints out a message with for a multipart suggestion without showing the suggested code.
     ///
     /// This is intended to be used for suggestions that are obvious in what the changes need to