about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-31 07:57:54 +0200
committerGitHub <noreply@github.com>2022-08-31 07:57:54 +0200
commitea9c370ffec63dc4a94e758790f31e6b14e8d5b5 (patch)
treef03e85857a99c676c131b583815a59b50dd5f30b /compiler/rustc_errors/src
parent7f442f8ba174fd4233a14ef4d7b577aa907db594 (diff)
parent31b939b3152ea70b2a84992905f48e125d85ca18 (diff)
downloadrust-ea9c370ffec63dc4a94e758790f31e6b14e8d5b5.tar.gz
rust-ea9c370ffec63dc4a94e758790f31e6b14e8d5b5.zip
Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwco
Allow deriving multipart suggestions

This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier.

r? ``@davidtwco``
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 506198df4d8..f75e2596f36 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -686,19 +686,12 @@ impl Diagnostic {
         suggestion: Vec<(Span, String)>,
         applicability: Applicability,
     ) -> &mut Self {
-        assert!(!suggestion.is_empty());
-        self.push_suggestion(CodeSuggestion {
-            substitutions: vec![Substitution {
-                parts: suggestion
-                    .into_iter()
-                    .map(|(span, snippet)| SubstitutionPart { snippet, span })
-                    .collect(),
-            }],
-            msg: self.subdiagnostic_message_to_diagnostic_message(msg),
-            style: SuggestionStyle::CompletelyHidden,
+        self.multipart_suggestion_with_style(
+            msg,
+            suggestion,
             applicability,
-        });
-        self
+            SuggestionStyle::CompletelyHidden,
+        )
     }
 
     /// Prints out a message with a suggested edit of the code.