about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-26 07:58:28 +0000
committerbors <bors@rust-lang.org>2022-10-26 07:58:28 +0000
commit629a414d7ba4caa3ca28b0a46c478e2ecb4c0059 (patch)
treeb1f78f8f0ab6047c65cd12fed875ff6240df9c14 /compiler/rustc_errors/src
parentd49e7e7fa13479c11a3733824c78e280e391288b (diff)
parent703fb66fa03f1ca4832d02aa274eecefa10ca029 (diff)
downloadrust-629a414d7ba4caa3ca28b0a46c478e2ecb4c0059.tar.gz
rust-629a414d7ba4caa3ca28b0a46c478e2ecb4c0059.zip
Auto merge of #103562 - Dylan-DPC:rollup-sheepp5, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #102951 (suggest type annotation for local statement initialed by ref expression)
 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)
 - #103287 (Use a faster allocation size check in slice::from_raw_parts)
 - #103416 (Name the `impl Trait` in region bound suggestions)
 - #103430 (Workaround unstable stmt_expr_attributes for method receiver expressions)
 - #103444 (Remove extra type error after missing semicolon error)
 - #103520 (rustc_middle: Rearrange resolver outputs structures slightly)
 - #103533 (Use &self instead of &mut self for cast methods)
 - #103536 (Remove `rustc_driver::set_sigpipe_handler()`)
 - #103542 (Pinning tests for some `macro_rules!` errors discussed in the lang meeting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index a63fc0ca285..23f29a24fe7 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -691,6 +691,24 @@ impl Diagnostic {
         suggestions: impl Iterator<Item = String>,
         applicability: Applicability,
     ) -> &mut Self {
+        self.span_suggestions_with_style(
+            sp,
+            msg,
+            suggestions,
+            applicability,
+            SuggestionStyle::ShowCode,
+        )
+    }
+
+    /// [`Diagnostic::span_suggestions()`] but you can set the [`SuggestionStyle`].
+    pub fn span_suggestions_with_style(
+        &mut self,
+        sp: Span,
+        msg: impl Into<SubdiagnosticMessage>,
+        suggestions: impl Iterator<Item = String>,
+        applicability: Applicability,
+        style: SuggestionStyle,
+    ) -> &mut Self {
         let mut suggestions: Vec<_> = suggestions.collect();
         suggestions.sort();
 
@@ -706,14 +724,15 @@ impl Diagnostic {
         self.push_suggestion(CodeSuggestion {
             substitutions,
             msg: self.subdiagnostic_message_to_diagnostic_message(msg),
-            style: SuggestionStyle::ShowCode,
+            style,
             applicability,
         });
         self
     }
 
-    /// Prints out a message with multiple suggested edits of the code.
-    /// See also [`Diagnostic::span_suggestion()`].
+    /// Prints out a message with multiple suggested edits of the code, where each edit consists of
+    /// multiple parts.
+    /// See also [`Diagnostic::multipart_suggestion()`].
     pub fn multipart_suggestions(
         &mut self,
         msg: impl Into<SubdiagnosticMessage>,
@@ -745,6 +764,7 @@ impl Diagnostic {
         });
         self
     }
+
     /// Prints out a message with a suggested edit of the code. If the suggestion is presented
     /// inline, it will only show the message and not the suggestion.
     ///