about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorFabian Wolff <fabi.wolff@arcor.de>2021-05-07 19:44:32 +0200
committerFabian Wolff <fabi.wolff@arcor.de>2021-05-07 20:46:49 +0200
commit439ef6d76279268eb80e33afffafa22597e22776 (patch)
treeac074896dd301b7f96ff18ddd281626a55205c64 /compiler/rustc_errors/src
parente5f83d24aee866a14753a7cedbb4e301dfe5bef5 (diff)
downloadrust-439ef6d76279268eb80e33afffafa22597e22776.tar.gz
rust-439ef6d76279268eb80e33afffafa22597e22776.zip
Fix suggestions for missing return type lifetime parameters
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index b2f6a0c1014..405dd2e68c6 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -299,6 +299,30 @@ impl Diagnostic {
         self
     }
 
+    /// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
+    pub fn multipart_suggestion_with_style(
+        &mut self,
+        msg: &str,
+        suggestion: Vec<(Span, String)>,
+        applicability: Applicability,
+        style: SuggestionStyle,
+    ) -> &mut Self {
+        assert!(!suggestion.is_empty());
+        self.suggestions.push(CodeSuggestion {
+            substitutions: vec![Substitution {
+                parts: suggestion
+                    .into_iter()
+                    .map(|(span, snippet)| SubstitutionPart { snippet, span })
+                    .collect(),
+            }],
+            msg: msg.to_owned(),
+            style,
+            applicability,
+            tool_metadata: Default::default(),
+        });
+        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