about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorSLASHLogin <loginmlgxd@gmail.com>2022-11-09 13:47:46 +0100
committerSLASHLogin <loginmlgxd@gmail.com>2022-11-09 14:57:54 +0100
commit39895b071645f2c377e4a9a3c16f92bc5c93c807 (patch)
tree3aa9f390c681ee3bd3ab08b3b363288598bda3b9 /compiler
parent0baac880fcddf4b63a1a1f8a9cd2cec3b984a45e (diff)
downloadrust-39895b071645f2c377e4a9a3c16f92bc5c93c807.tar.gz
rust-39895b071645f2c377e4a9a3c16f92bc5c93c807.zip
Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, Style)>`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/write.rs3
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs15
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs
index f0e2e43509f..e3d28a1aca2 100644
--- a/compiler/rustc_codegen_ssa/src/back/write.rs
+++ b/compiler/rustc_codegen_ssa/src/back/write.rs
@@ -1787,8 +1787,7 @@ impl SharedEmitterMain {
             match message {
                 Ok(SharedEmitterMessage::Diagnostic(diag)) => {
                     let handler = sess.diagnostic();
-                    let mut d = rustc_errors::Diagnostic::new(diag.lvl, String::new());
-                    d.message = diag.msg;
+                    let mut d = rustc_errors::Diagnostic::new_with_messages(diag.lvl, diag.msg);
                     if let Some(code) = diag.code {
                         d.code(code);
                     }
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index b24814bfa38..0ee4c6e722f 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -214,6 +214,21 @@ impl Diagnostic {
     }
 
     #[track_caller]
+    pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
+        Diagnostic {
+            level,
+            message: messages,
+            code: None,
+            span: MultiSpan::new(),
+            children: vec![],
+            suggestions: Ok(vec![]),
+            args: Default::default(),
+            sort_span: DUMMY_SP,
+            is_lint: false,
+        }
+    }
+
+    #[track_caller]
     pub fn new_with_code<M: Into<DiagnosticMessage>>(
         level: Level,
         code: Option<DiagnosticId>,