]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_errors/diagnostic_builder.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_errors / diagnostic_builder.rs
index 008d2e92418f9b89f38cf83e74c3808a48d69a5a..2dbd9f4e52fad36f5633d7faf18fc224771b51d6 100644 (file)
@@ -162,7 +162,7 @@ impl<'a> DiagnosticBuilder<'a> {
         message: &str,
         span: Option<S>,
     ) -> &mut Self {
-        let span = span.map(|s| s.into()).unwrap_or_else(|| MultiSpan::new());
+        let span = span.map(|s| s.into()).unwrap_or_else(MultiSpan::new);
         self.0.diagnostic.sub(level, message, span, None);
         self
     }
@@ -315,6 +315,20 @@ impl<'a> DiagnosticBuilder<'a> {
         self
     }
 
+    pub fn span_suggestion_verbose(
+        &mut self,
+        sp: Span,
+        msg: &str,
+        suggestion: String,
+        applicability: Applicability,
+    ) -> &mut Self {
+        if !self.0.allow_suggestions {
+            return self;
+        }
+        self.0.diagnostic.span_suggestion_verbose(sp, msg, suggestion, applicability);
+        self
+    }
+
     pub fn span_suggestion_hidden(
         &mut self,
         sp: Span,